我有以下“按钮工具栏”布局设置:
我希望按钮栏(RelativeLayout)的高度为屏幕高度的10%,因此我使用了layout_weight =“0.1”+ layout_weight =“0.9”,但不超过86个像素,因此我尝试使用maxHeight =“86px”,但这不起作用。
您有任何提示如何实现10%高度与恒定最大高度布局限制吗?
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<RelativeLayout
android:id="@+id/button_bar"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="0.1"
android:maxHeight="86px"
android:orientation="horizontal">
<Button
android:id="@+id/home_button"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_alignParentLeft="true"/>
<Button
android:id="@+id/level_button"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_toRightOf="@+id/home_button"/>
<Button
android:id="@+id/help_button"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_toRightOf="@+id/level_button"/>
<Button
android:id="@+id/sound_button"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_alignParentRight="true"/>
</RelativeLayout>
<View
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="0.9"/>
</LinearLayout>
我希望按钮栏(RelativeLayout)的高度为屏幕高度的10%,因此我使用了layout_weight =“0.1”+ layout_weight =“0.9”,但不超过86个像素,因此我尝试使用maxHeight =“86px”,但这不起作用。
您有任何提示如何实现10%高度与恒定最大高度布局限制吗?
RelativeLayout
的 API 没有包括maxHeight
属性(View
或ViewGroup
也没有)。这就是为什么我认为它在你的代码中没有被尊重的原因。 - Flo