Rob*_*b85 5 java android android-layout
我有一个布局,其中有四个按钮分布在我的应用程序底部,使用布局权重均匀分布它们。
我还想使用相同的权重来增加按钮的高度。
到目前为止,我只能看到使用水平线性布局计算宽度或使用垂直线性布局计算高度。
宽度工作得很好,只是高度。
如果不能同时使用重量,我如何设置高度,使其在每个屏幕尺寸上都是相对的。
<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>
我不想硬编码按钮的高度
Buttons 的高度设置为fill_parentLinearLayout在垂直 LinearLayoutLinearLayout的重量 <- 现在这是一个垂直的重量,会影响你Button的身高按钮应正确调整大小
| 归档时间: | 
 | 
| 查看次数: | 2505 次 | 
| 最近记录: |