Android: trying to understand android:layout_weight

前端 未结 2 1447
名媛妹妹
名媛妹妹 2020-12-13 10:51

I\'m trying to divide a page in three parts. I\'d like to do it in percentage values, however that is not supported by Android. Instead I have to use android:layout_we

2条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-13 11:19

    When you use android:layout_height="fill_parent" for the bars, you are not leaving any available space. (Since they are filling the parent.) Because all 3 are set to fill, the requested height is actually 3x the parent height, so the weights are being applied to a negative remaining space. This explains the weird behavior you are seeing, and why setting layout_height to 0px solves it.

提交回复
热议问题