以及你不能強迫留在底部在平板電腦上,但如果手機是啊,你可以通過清單來做到這一點。但你可以做一些類似於底部欄和頂部欄的東西。 在這個例子中,我會告訴你如何使用merge來輕鬆完成,而不需要使用android的ActionBar。
您需要創建的第一件事是您的main_activity.xml
在我的情況下,main_activity.xml
僅在RelativeLayout上包含ImageView
。這裏是代碼。
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity" >
<RelativeLayout android:id="@+id/RelativeLayout04"
android:layout_width="match_parent" android:layout_height="wrap_content"
android:layout_alignParentTop="true">
<include layout="@layout/header" />
</RelativeLayout>
<ImageView
android:id="@+id/view"
android:layout_width="match_parent"
android:layout_height="200dp"
android:layout_above="@+id/RelativeLayout03"
android:layout_below="@+id/RelativeLayout04"
android:layout_centerHorizontal="true"
android:src="@android:drawable/alert_dark_frame" />
<RelativeLayout android:id="@+id/RelativeLayout03"
android:layout_width="match_parent" android:layout_height="wrap_content"
android:layout_alignParentBottom="true">
<include layout="@layout/tryit" />
</RelativeLayout>
,你可以看到在上面的代碼中,有兩個合併我把裏面的main_activity.xml
一個在底部的定義,一個在頂部定義。 這裏是假底部酒吧xml。
<merge xmlns:android="http://schemas.android.com/apk/res/android">
<LinearLayout
android:id="@+id/LinearLayout01"
android:layout_width="match_parent"
android:layout_height="80dp"
android:layout_weight="0.14"
android:background="@drawable/dock" >
<ImageView
android:id="@+id/dark"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="0.14" />
<ImageView
android:id="@+id/stock"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="0.14" />
<ImageView
android:id="@+id/open"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="0.14" />
<ImageView
android:id="@+id/border"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="0.15" />
<ImageView
android:id="@+id/color"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="0.15"
/>
</LinearLayout>
我把一個固定的背景,LinearLayout
和僞造的ImageView爲onClicks。
這裏是頂尖的酒吧。 `
<LinearLayout
android:id="@+id/LinearLayout02"
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_weight="0.14"
android:background="@drawable/dock1"
android:layout_gravity="top">
<ImageView
android:id="@+id/darka"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="0.14" />
<ImageView
android:id="@+id/stocka"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="0.14" />
<ImageView
android:id="@+id/opena"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="0.14" />
<ImageView
android:id="@+id/bordera"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="0.15" />
<ImageView
android:id="@+id/colora"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="0.15"
/>
</LinearLayout>
'
其也從上述底部欄複製粘貼。只需將android:layout_alignParentBottom="true"
中的一項更改爲android:layout_alignParentTop="true"
即可,並且您在底部和頂部都有一個actionBar。在這種情況下,你不會需要使用動作條,所以我建議你使用Theme.Holo.NoActionBar
這裏是圖像結果: - http://i.imgur.com/N8uKg6v.png
這是一個項目,我的工作現在。完成了幾乎所有的事情,但仍然與設計掙扎。希望我的回答能讓你受益。如果您覺得有趣,請回答問題。
此致敬意。 〜Kosh
你可能在使用程序兼容性。 在ActionBarCompat中,通過在清單中將 'android.support.UI_OPTIONS'元數據字段設置爲'splitActionBarWhenNarrow'來完成此操作。 –
SAIR