Understanding measureWithLargestChild: Why breaks the layout?

I'm playing with the option measureWithLargestChild="true". I don't understand why my layout breaks total, if one of my buttons has a too big text onto it. I think it should keep the basic size of 1/3 but they gets smaller about 1/6. Why is that?

Here can you see some screenshots:

Here is my xml:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:baselineAligned="false"
    android:gravity="center"
    android:orientation="vertical" >
    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:baselineAligned="false"
        android:measureWithLargestChild="true" >
        <Button
            style="@style/my_style"
            android:layout_weight="1"
            android:text="Button123456" />
        <Button
            style="@style/my_style"
            android:layout_weight="1"
            android:text="A" />
        <Button
            style="@style/my_style"
            android:layout_weight="1"
            android:text="WW" />
    </LinearLayout>
</LinearLayout>

Answers


I believe this is a bug in measure algorithm. There is following comment in LinearLayout.measureHorizontal(int, int) method.

// Either expand children with weight to take up available space or
// shrink them if they extend beyond our current bounds

It says, the algorithm will shrink items with weight if there is not enough space for them. As measureWithLargestChild is set to true, all items have the same width as the most left item. Now they all together don't fit into the parent's width anymore. Thus they will be shrank. If there were no bug, all items would have same width afterwards. But due to the bug, algorithm shrinks original (wrap_content) widths instead of widths calculated according to measureWithLargestChild attribute. That's why two items on the right became smaller.


Need Your Help

Simplest way to have a configuration file in a Windows Forms C# Application

.net xml winforms configuration

I'm really new to .NET and I still didn't get the hang about how config files work.

Fresh RVM Installation on OS X, not able to run server due to sqlite3 issues

ruby-on-rails sqlite3 rvm

I installed rvm on my Mac OS X 10.6.8 (running Snow Leopard) and tried to start up my first sample app. After a few hours of fiddling around with the gems, I decided to post the issue here, because I

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.