的Google+應用有一個佈局,其中它在主操作杆和下操作欄項目。目前我正在使用android:uiOptions="splitActionBarWhenNarrow"
將項目放置在底部欄中。我怎樣才能把物品放在頂部和底部?
回答
當頂部欄中顯示的項目多時,底部欄會被填滿。
而不是顯示「溢出」三點的項目將被放在底部欄。請記住在XML中的菜單項上使用:
android:showAsAction="ifRoom|withText"
。
更多在這裏閱讀: http://developer.android.com/guide/topics/ui/actionbar.html#SplitBar
這看起來不對。在Google+示例中,它們頂部也有溢出圖標。 – PolandSpring 2012-02-17 22:11:46
@kkshin這是一個自定義視圖,而不是默認的分割操作欄。 – doorstuck 2012-02-20 12:03:52
我試過這個,但它只是在底部的操作欄中進行。 – Timmmm 2012-08-19 17:17:35
我不使用標準的動作條認爲這是可能的。當啓用拆分ActionBar時,ALL操作將顯示在屏幕的底部。
Google+應用「創建帖子」活動的底部欄似乎是自定義實現。注意長按以顯示動作標籤不起作用,即使切換到橫向時底部條仍然存在。位置項目是一個切換開關,它也是非標準的ActionBar行爲。
希望我的回答對你來說不算太晚。
- 使用
android:uiOptions="splitActionBarWhenNarrow"
(這增加了底部欄的東西)。 創建如下代碼的新佈局(此佈局將處理頂部欄上的所有項目)。
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="wrap_content" android:gravity="right" > <Switch android:id="@+id/switch1" android:layout_width="wrap_content" android:layout_height="match_parent"/> <ImageButton android:id="@+id/action_starred" android:layout_width="wrap_content" android:layout_height="wrap_content" style="?android:attr/actionButtonStyle" android:src="@android:drawable/ic_menu_compass" android:onClick="FakeMenu"/> </LinearLayout>
在您的活動粘貼此
ActionBar actionBar = getActionBar(); actionBar.setCustomView(R.layout.actionbar_top); //load your layout actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_HOME|ActionBar.DISPLAY_SHOW_CUSTOM); //show it
這是所有:)
你幫了我很多,謝謝!對於那些使用ActionBarSherlock庫的人來說,可以使用getSherlock()。getActionBar()來獲得您的操作欄對象。 – lopek 2013-06-01 23:11:14
如何在頂部顯示流量菜單而不是底部? – samirprogrammer 2013-10-01 18:50:54
我有同樣的問題,沒有什麼,我發現真的工作,因爲我不得不處理隨着操作欄的縮小,然後在大型設備上,按鈕被放置在頂部而不是底部。所以,我終於解開了它在主要佈局放置一個「頁腳」:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="wrap_content">
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignParentTop="false"
android:layout_above="@+id/footer">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:id="@+id/container"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:paddingLeft="@dimen/body_padding_large"
android:paddingRight="@dimen/body_padding_large"
android:paddingTop="@dimen/body_padding_medium"
android:paddingBottom="@dimen/body_padding_medium"
android:gravity="top">
</LinearLayout>
</ScrollView>
<LinearLayout android:id="@+id/footer"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_alignParentBottom="true"
style="@android:style/ButtonBar">
<Button android:id="@+id/btn_1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Button 1" />
<Button android:id="@+id/btn_2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Button 2" />
</LinearLayout>
</RelativeLayout>
<?xml version="1.0" encoding="utf-8"?>
< LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="right" >
<Switch
android:id="@+id/switch1"
android:layout_width="wrap_content"
android:layout_height="match_parent"/>
<ImageButton
android:id="@+id/action_starred"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="?android:attr/actionButtonStyle"
android:src="@android:drawable/ic_menu_compass"
android:onClick="FakeMenu"/>
</LinearLayout>
//Then put these lines of code in your java class or activity
ActionBar actionBar = getActionBar();
actionBar.setCustomView(R.layout.actionbar); //load your layout
actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_HOME|ActionBar.DISPLAY_SHOW_USTOM); //show it
//希望這有助於
在這種情況下,如果您有權利,您可以投票回答(如果不需要評論)。 但是,如果您找到解決問題的另一種方法,請隨時分享。 – TocToc 2016-06-15 08:04:47
- 1. 浮動酒吧藏匿,需要放置
- 2. Android動作酒吧定製
- 3. 行動項目在Android的動作條
- 4. 測序動作條項目
- 5. 底部酒吧頂部的浮動動作按鈕
- 6. 如何給不同的動作的動作條項目
- 7. Android的動作條行動項目
- 8. 意圖在行動酒吧不工作
- 9. 用動作顯示搜索欄(酒吧項目)
- 10. 動作條選項
- 11. 動作酒吧夏洛克黑暗主題與燈光主題+黑暗行動酒吧
- 12. 安卓:滾動型+ ViewFlipper +底酒吧
- 13. 進度條健康酒吧
- 14. 溢出動作項動作條
- 15. 在動作條
- 16. 在動作條
- 17. 動作條Actionmenu項目圖標不vissible
- 18. ClickListener自定義動作條項目(ActionBarSherlock)
- 19. STDIN酒吧在底部
- 20. 奇巧Transucency只是在底部的酒吧和一個活動
- 21. 如何移動導航欄內的酒吧按鈕項目
- 22. 獲取滑動條以響應點擊任何沿着酒吧
- 23. 酒吧放置int Androidplot
- 24. 如何添加更多酒吧到這個動畫jQuery,CSS和HTML條形圖
- 25. 如何在pygame中放置滾動條?
- 26. 動作條菜單項
- 27. Android底部條形菜單onclick動作
- 28. 酒吧不顯示在jqplot條形圖
- 29. 序在prettyplotlib條形圖酒吧
- 30. 佈局 - 如何填補頂部酒吧和底部酒吧之間的差距
是如何在頂部顯示菜單圖標??? – samirprogrammer 2013-10-01 18:53:05