Reputation: 11
I try to make ActionBar at bottom with image and text on Android 4.3
First I write main.xml file for menu
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:id="@+id/action_search"
android:orderInCategory="100"
android:showAsAction="always|withText"
android:icon="@drawable/city"
android:title="@string/home_icon"/>
<item
android:id="@+id/action_copy"
android:orderInCategory="100"
android:showAsAction="always|withText"
android:icon="@drawable/map"
android:title="@string/mapa_icon"/>
</menu
>
After that I put some lines in Manifest file
<meta-data android:name="android.support.UI_OPTIONS"
android:value="splitActionBarWhenNarrow" />
After all this I get Action bar at bottom but without text just images.. Also I try to put Button and textView on main.xml with drawable part and get same like first time.
Please any solution , or how to get icons with image on bottom ActionBar
Upvotes: 1
Views: 2204
Reputation: 13902
you can try
android:showAsAction="ifRoom|withText"
to show the menu title along with the icon.
the actual suggestion from http://developer.android.com/guide/topics/ui/actionbar.html
If your menu item supplies both a title and an icon—with the title and icon attributes—then the action item shows only the icon by default. If you want to display the text title, add "withText" to the showAsAction attribute. For example:
Note: The "withText" value is a hint to the action bar that the text title should appear. The action bar will show the title when possible, but might not if an icon is available and the action bar is constrained for space.
but this does not work in ICS+
for a detailed discussion on why this won't work:
android 4.0, text on the action bar NEVER shows
Upvotes: 2
Reputation: 12042
try like this refer this documentation to know how to add the view in bottom actionbar
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.main_activity_actions, menu);
MenuItem searchItem = menu.findItem(R.id.action_search);
SearchView searchView = (SearchView) MenuItemCompat.getActionView(searchItem);
// Configure the search info and add any event listeners
...
return super.onCreateOptionsMenu(menu);
}
Upvotes: 0