How to Style the Menu Items on an Android Action Bar

How to style the menu items on an Android action bar

Instead of having the android:actionMenuTextAppearance item under your action bar style, move it under your app theme.

Action Bar menu item text color

Try something like this :

<style name="ThemeName" parent="@style/Theme.Sherlock.Light">
<item name="actionMenuTextColor">@color/white</item>
<item name="android:actionMenuTextColor">@color/white</item>
</style>

Android action bar options menu item custom selectable background

You can try setting the android:actionBarItemBackground attribute in styles, like so:

<style name="AppTheme" parent="android:Theme.Material">
...
<item name="android:actionBarItemBackground">?android:selectableItemBackground</item>
</style>

Android ActionBar overflow menu style

Actually you can't do anything with this icon, but you can create menu item with android:actionLayout="@layout/custom_lauout". Then you can create Popup Window, which allows such positioning. In popupWindow you will show all items that must show under "three dots item".

Here rea a few links which can help you: http://developer.android.com/reference/android/widget/PopupWindow.html
https://stackoverflow.com/a/23516493/3864698

Options Menu in Action Bar Displays option too high up

Use actionOverflowMenuStyle and put a custom style inside AppTheme in styles.xml like this, where you'll turn overlapAnchor to false and set an offset for it:

<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="actionOverflowMenuStyle">@style/OptionsMenuCustomStyle</item>
</style>

<style name="OptionsMenuCustomStyle" parent="Widget.AppCompat.PopupMenu.Overflow">
<item name="overlapAnchor">false</item>
<item name="android:overlapAnchor" tools:ignore="NewApi">false</item>
<item name="android:dropDownVerticalOffset">4.0dip</item>
</style>

The out would look exactly like your requirement:

Sample Image

Change ActionBar Menu Icons depending on Style

Solved it, but gave it up to try it with XML, I did it now programmatically:

@Override
public boolean onCreateOptionsMenu(Menu menu) {
SharedPreferences prefs = getSharedPreferences("app", 0);
boolean isDark = "Dark".equals(prefs.getString("theme", "Dark"));

com.actionbarsherlock.view.MenuInflater inflater = getSupportMenuInflater();
inflater.inflate(R.menu.main, menu);

// set Icons
menu.findItem(R.id.menuitem_search).setIcon(isDark ? R.drawable.action_search : R.drawable.action_search_light);
menu.findItem(R.id.menuitem_add).setIcon(isDark ? R.drawable.content_new : R.drawable.content_new_light);
menu.findItem(R.id.menuitem_share).setIcon(isDark ? R.drawable.social_share : R.drawable.social_share_light);
return true;
}


Related Topics



Leave a reply



Submit