如何使用4.0.3 SDK在活动底部创建菜单栏 [英] how to create menu bar at bottom of the activity using 4.0.3 SDK
问题描述
我正在4.0.3中创建菜单,根据文档显示,菜单栏总是在活动顶部显示菜单栏,但我想在活动底部显示菜单栏,如何实现?
I am creating a menu in 4.0.3, according to documentation it always shows menu bar at the top of my activity but i want to show it at the bottom of my activity like that.How can i achieve this?
当前我正在使用以下代码.
Currently i am using the following code.
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}}
menue.xlm
menue.xlm
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:id="@+id/weather"
android:showAsAction="always|withText"
android:icon="@drawable/ic_launcher"
android:title="weather"/>
<item
android:id="@+id/second"
android:icon="@drawable/ic_launcher"
android:showAsAction="always|withText"
android:title="Home"/>
<item
android:id="@+id/java"
android:icon="@drawable/ic_launcher"
android:showAsAction="always|withText"
android:title="Java"/>
<item
android:id="@+id/android"
android:icon="@drawable/ic_launcher"
android:showAsAction="always|withText"
android:title="Android"/>
</menu>
维护
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.example.bottom.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
,它显示以下输出.
and it showing the following output.
推荐答案
据我所知,没有选择将ActionBar
完全移到底部.但是仍然可以在底部显示少量项目.为此,您需要执行以下操作:
As far as i know there is no option to move the ActionBar
entirely to the bottom. But still it is possible to display few items at the bottom. for that you need to do this:
-
只需将
android:uiOptions="splitActionBarWhenNarrow"
添加到AndroidManifest.xml
中的activity
标记中,就像这样...
Just add
android:uiOptions="splitActionBarWhenNarrow"
to youractivity
tag in theAndroidManifest.xml
like this...
<activity
android:name=".MainActivity"
android:uiOptions="splitActionBarWhenNarrow">
<activity
android:name=".MainActivity"
android:uiOptions="splitActionBarWhenNarrow">
希望它会有所帮助. :)
Hope it helps. :)
这篇关于如何使用4.0.3 SDK在活动底部创建菜单栏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!