Reputation: 167
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
<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>
Mainfest
<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.
Upvotes: 1
Views: 13144
Reputation: 6736
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:
Just add android:uiOptions="splitActionBarWhenNarrow"
to your activity
tag in theAndroidManifest.xml
like this...
<activity
android:name=".MainActivity"
android:uiOptions="splitActionBarWhenNarrow">
You can read more here and here
Hope it helps. :)
Upvotes: 4