2个选项:
1)您可以只在清单中设置标志(或像上面那样以编程方式)来拆分ActionBar
,但这仅适用于您在手机大小的纵向设备上,即使这样它仍然有ActionBar
现在的顶部,但是将前几个ActionItem
s 移到底部。这在大多数情况下都很好,但听起来你是在说你总是希望这个底部显示,而你将使用的系统菜单无法按照你想要的程度设置样式。
2)为屏幕底部制作自己的布局,以创建您正在谈论的样式菜单。这可能有效:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:orientation="vertical" >
<!-- this is where the Activity contents go -->
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_alignParentBottom="true"
android:background="#8f8"
android:orientation="horizontal" >
<!-- this is the green bottom bar -->
</LinearLayout>
<LinearLayout
android:layout_width="48dp"
android:layout_height="70dp"
android:layout_alignParentBottom="true"
android:layout_alignParentleft="true"
android:layout_margin="5dp"
android:orientation="vertical" >
<!-- This is the status button -->
<ImageView
android:layout_width="48dp"
android:layout_height="40dp"
android:background="#00f" />
<TextView
android:layout_width="48dp"
android:layout_height="wrap_content"
android:padding="4dp"
android:text="Status"
android:textAlignment="center"
android:textSize="12sp" />
</LinearLayout>
<LinearLayout
android:layout_width="60dp"
android:layout_height="70dp"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_margin="5dp"
android:orientation="vertical" >
<!-- This is the Pet Open button -->
<ImageView
android:layout_width="60dp"
android:layout_height="40dp"
android:background="#00f" />
<TextView
android:layout_width="60dp"
android:layout_height="wrap_content"
android:padding="4dp"
android:text="Pet Open"
android:textAlignment="center"
android:textSize="12sp" />
</LinearLayout>
<LinearLayout
android:layout_width="60dp"
android:layout_height="70dp"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_margin="5dp"
android:orientation="vertical" >
<!-- This is the Refresh button -->
<ImageView
android:layout_width="60dp"
android:layout_height="40dp"
android:background="#00f" />
<TextView
android:layout_width="60dp"
android:layout_height="wrap_content"
android:padding="4dp"
android:text="Refresh"
android:textAlignment="center"
android:textSize="12sp" />
</LinearLayout>
</RelativeLayout>
这将适用于 3 个按钮,并进行一系列调整以使其样式更接近您想要的样式。如果您希望底部出现超过 3 个,并且您想使用提供MenuItem
的 's,您可以在运行时确定所有这些onPrepareOptionsMenu()
,并动态更改上面布局的版本。那将是更多的工作,但可能是您正在寻找的更多。