SidingMenu佈局:
您應該設置一個ListView
的菜單佈局。接下來,創建sliding_menu_header.xml
佈局ImageView
和TextView
內:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="vertical" >
<ImageView
android:src="@drawable/image_source"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<TextView
android:text="text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
現在,你可以擡高這個佈局,並將其設置爲ListView
的頭球觀點:
View menuHeader = getLayoutInflater().inflate(R.layout.sliding_menu_header, null);
mListView.addHeaderView(menuHeader);
mListView.setAdapter(mYourMenuAdapter);
動作條的佈局:
您可以將自定義視圖添加到ActionBar
。你的情況的佈局可以像:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="horizontal" >
<Button
android:id="@+id/button1"
android:text="button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<Button
android:id="@+id/button2"
android:text="button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
以下行然後添加到您的onCreate
方法:
ActionBar actionBar = getSupportActionBar();
actionBar.setCustomView(R.layout.actionbar_view);
actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM
| ActionBar.DISPLAY_SHOW_HOME);
Button button1 = actionBar.getCustomView.findViewById(R.id.button1);
Button button2 = actionBar.getCustomView.findViewById(R.id.button2);
希望這將有助於你。如果我的回答不完整,請發表評論,我會更新它。
@Gaston F.是否有效?請接受我的答案,如果我幫你 – Aspicas
謝謝你的鏈接,我已經看到了這些信息,這些庫和我已經安裝的例子,但我無法做screen2(通過鏈接的imagecontrol),我不能添加button1和按鈕2在頂欄上(見最後一張圖片)。如果您有解決方案,請欣賞幫助。謝謝 –
你想要像「標籤」或只有一個圖標的按鈕按鈕? – Aspicas