如何将动作条项目的主要动作条和底酒吧 [英] How to Place ActionBar Items in Main ActionBar and Bottom Bar
本文介绍了如何将动作条项目的主要动作条和底酒吧的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Google+应用有一个布局,其中它在主操作栏和底部的操作栏项目。目前我使用的Android版本:uiOptions =splitActionBarWhenNarrow放置在底栏项目。我怎么能放在顶部和底部的项目?
The Google+ app has a layout where it has action bar items in the main action bar and the bottom. Currently I am using android:uiOptions="splitActionBarWhenNarrow" to place items in the bottom bar. How can I place items on both the top and bottom?
推荐答案
希望我的回答是不是已经太晚了。
Hope my answer is not too late for you.
- 使用安卓uiOptions =splitActionBarWhenNarrow(这增加了东西到底栏)。
-
创建像下面的code新的布局(这种布局将处理所有项目上的顶栏)。
- Use android:uiOptions="splitActionBarWhenNarrow" (this adds stuff into bottom bar).
Create new layout like the below code (this layout will handle all your items on the topbar).
<?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>
在您的活动复制粘贴此
Paste this in your activity
ActionBar actionBar = getActionBar();
actionBar.setCustomView(R.layout.actionbar_top); //load your layout
actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_HOME|ActionBar.DISPLAY_SHOW_CUSTOM); //show it
这就是:)
That's all :)
这篇关于如何将动作条项目的主要动作条和底酒吧的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文