android - Understanding measureWithLargestChild: Why breaks the layout? -


i'm playing option measurewithlargestchild="true". don't understand why layout breaks total, if 1 of buttons has big text onto it. think should keep basic size of 1/3 gets smaller 1/6. why that?

here can see screenshots:

button layout bug

here 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> 

i believe bug in measure algorithm. there following comment in linearlayout.measurehorizontal(int, int) method.

// either expand children weight take available space or // shrink them if extend beyond our current bounds 

it says, algorithm shrink items weight if there not enough space them. measurewithlargestchild set true, items have same width left item. don't fit parent's width anymore. shrank. if there no bug, items have same width afterwards. due bug, algorithm shrinks original (wrap_content) widths instead of widths calculated according measurewithlargestchild attribute. that's why 2 items on right became smaller.


Comments

Popular posts from this blog

php - Why I am getting the Error "Commands out of sync; you can't run this command now" -

linux - Does gcc have any options to add version info in ELF binary file? -

java - Are there any classes that implement javax.persistence.Parameter<T>? -