[英]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.