我有一个布局,其中有四个按钮沿着我的应用程序底部分布,使用布局权重将它们均匀分布。
我还想使用相同的权重来增加按钮的高度。
到目前为止,我所能看到的只是使用水平线性布局计算宽度或使用垂直线性布局计算高度。
宽度效果很好,只是高度。
如果重量不能同时使用,我如何设置高度,以便它在每个屏幕尺寸上都是相对的。
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:weightSum="1.0"
android:gravity="bottom">
<ImageButton
android:id="@+id/Button1"
android:layout_width="fill_parent"
android:layout_height="80dp"
android:layout_weight="0.25"
android:src="@drawable/b1"
android:text="Left" />
<ImageButton
android:id="@+id/Button2"
android:layout_width="fill_parent"
android:layout_height="80dp"
android:layout_weight="0.25"
android:src="@drawable/b2"
android:text="RotL" />
<ImageButton
android:id="@+id/Button3"
android:layout_width="fill_parent"
android:layout_height="80dp"
android:layout_weight="0.25"
android:src="@drawable/b3"
android:text="RotR" />
<ImageButton
android:id="@+id/Button4"
android:layout_width="fill_parent"
android:layout_height="80dp"
android:layout_weight="0.25"
android:src="@drawable/b4"
android:text="Right" />
</LinearLayout>
我不想对按钮的高度进行硬编码
- 设置你的
Button
s 的高度为fill_parent
- 放置您的水平的
LinearLayout
in a vertical LinearLayout
- Set the 水平的
LinearLayout
的重量 Buttons 的高度
按钮应正确调整大小
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)