How does android:layout_weight work?

前端 未结 8 2095
后悔当初
后悔当初 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 21:07

    If the orientation of linearlayout is vertical,then set layout_height as 0dp. In case of horizontal layout set layout_width as 0dp.

    If we do not follow above rules,the view tends to take up space as per specified attributes and hence the alignment is not as per expectation.

提交回复
热议问题