Tôi đang chơi với tùy chọn measureWithLargestChild="true"
. Tôi không hiểu tại sao bố cục của tôi bị hỏng tổng cộng, nếu một trong các nút của tôi có văn bản quá lớn trên đó. Tôi nghĩ rằng nó nên giữ kích thước cơ bản là 1/3 nhưng chúng nhỏ hơn khoảng 1/6. Tại sao vậy?Hiểu measureWithLargestChild: Tại sao ngắt bố cục?
đây bạn có thể thấy một số ảnh chụp màn hình:
Đây là xml của tôi:
<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>
Ai đó có thể vui lòng giải thích lý do tại sao nó bị thu hẹp trong trường hợp 2 (trong số 4 trường hợp). Làm thế nào đến không có không gian có sẵn trong trường hợp này? – Diffy