[英]Android Constant Menu for app
您可以使用片段来实现。 http://developer.android.com/guide/topics/fundamentals/fragments.html
当您的应用启动时,您会加载一个称为HomeActivity或其他的活动。 此活动应加载如下所示的布局:
<?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"
android:orientation="vertical" >
<RelativeLayout
android:id="@+id/fragment_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="@+id/relativeLayout1"
android:layout_alignParentTop="true" >
</RelativeLayout>
<RelativeLayout
android:id="@+id/relativeLayout1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true" >
<Button
android:id="@+id/btnFirst"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:text="@string/btn_previous" />
<Button
android:id="@+id/btnSecond"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:text="@string/btn_pause" />
<Button
android:id="@+id/btnThird"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:text="@string/btn_next" />
</RelativeLayout>
</RelativeLayout>
如您所见,您的3个按钮始终位于屏幕底部。 不用调用其他活动,而是将RelativeLayout“ fragment_container”中的片段替换为要显示的片段。 这意味着您必须使用“片段类”来更改“活动类”。 片段和活动非常安静,因此更改代码不应该很困难。
在Android中,用于显示导航和操作项的首选方法是使用ActionBar,该模式具有一种称为“拆分操作栏”的模式,可以在屏幕的顶部和底部进行拆分(通常沿着屏幕顶部和底部拆分)。最佳)。 这是专为您要描述的情况而设计的。 您可以在Android设计指南中阅读有关操作栏的设计指南 。
要创建拆分操作栏,请从“ 开发人员指南”中 ,
要启用拆分操作栏,只需将uiOptions =“ splitActionBarWhenNarrow”添加到您或清单元素中。
请记住,根据设计指南,导航元素应位于顶部,而动作(播放,暂停,电子邮件等)应位于底部。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.