Java 底部的操作栏选项卡?
我正试图将操作栏标签放在我的应用程序底部,但我需要一些帮助(如果可能的话) 守则:Java 底部的操作栏选项卡?,java,android,Java,Android,我正试图将操作栏标签放在我的应用程序底部,但我需要一些帮助(如果可能的话) 守则: actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); ActionBar.Tab tabA = actionBar.newTab().setText("Games"); ActionBar.Tab tabB = actionBar.newTab().setText("Apps"); ActionB
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
ActionBar.Tab tabA = actionBar.newTab().setText("Games");
ActionBar.Tab tabB = actionBar.newTab().setText("Apps");
ActionBar.Tab tabC = actionBar.newTab().setText("Themes");
tabA.setTabListener(new ActionBarTabListener());
tabB.setTabListener(new ActionBarTabListener());
tabC.setTabListener(new ActionBarTabListener());
actionBar.addTab(tabA);
actionBar.addTab(tabB);
actionBar.addTab(tabC);
将标签放在底部有点违背安卓的指导原则,但a应该能够完成您想要做的事情。还有另一种方法,但您必须使用FrgamentTabHost 这是代码。 布局/活动\u main.xml
enter <android.support.v4.app.FragmentTabHost
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/tabhost"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1" />
<TabWidget
android:id="@android:id/tabs"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"/>
</LinearLayout>
我已经试过了,但是标签仍然在顶部。。。唯一移到底部的是菜单项。您可能只需要实现自定义选项卡或使用ViewPager和ViewPagerIndicator,我不确定stock操作栏是否能够具有底部选项卡。您是否找到了解决方案?@powder366使用ViewPager和TablPagerIndicator可以非常轻松地完成此任务
enter code here<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_horizontal"
android:orientation="vertical"
android:background="#eaecee">
<TextView
android:id="@+id/text"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_vertical|center_horizontal"
android:text="@string/hello_world"
android:textAppearance="?android:attr/textAppearanceMedium" />