How does android:layout_weight work?

前端 未结 8 2097
后悔当初
后悔当初 2020-12-02 20:35

When I have the following, it shows top layout with four colors has much smaller area than the bottom layout area.

According to this documentation, when you add more

8条回答
  •  情书的邮戳
    2020-12-02 20:52

    I know this is late but hopefully it helps people:

    Use android:weightSum on the parent. Here is a link to the dev docs.

    http://developer.android.com/reference/android/widget/LinearLayout.html#attr_android:weightSum

    Use android:weightSum of 1.0 on the parent and then use 0.x on the child views with android:layout_weight in order for them to use that ratio of space.

提交回复
热议问题