xml-Android百分比布局高度
我知道无法设置百分比,并且可以设置某些图像的权重以缩放其高度。 我要尝试做的是指定相对于其内部布局的布局高度。 基本上我有这样的东西
当然,这是一个非常简化的版本,以便您可以理解我的胡言乱语。 基本上,我想将内部线性布局设置为主要线性布局的50%左右。
做这个的最好方式是什么?
Somk asked 2020-02-04T00:29:05Z
5个解决方案
106 votes
有一个名为android:weightSum的属性。
您可以在父linear_layout中设置android:weightSum =“ 2”,在内部linear_layout中设置android:weight =“ 1”。
请记住,将内部linear_layout设置为fill_parent,以便weight属性可以按预期工作。
顺便说一句,我认为没有必要添加第二个视图,尽管我没有尝试过。 :)
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:weightSum="2">
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:layout_weight="1">
Axel M.