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:
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
Android E/Parcel﹕ Class Not Found When Unmarshalling (Only on Samsung Tab3)
How to Change Background Color Popup Menu Android
Httpentity Is Deprecated on Android Now, What's the Alternative
Android Gradle Build Error:(9, 0) Gradle Dsl Method Not Found: 'Compile()'
Connect to Wifi in Android Q Programmatically
Font Size Too Large to Fit in Cache
How to Shutdown an Android Mobile Programmatically
Topics on Firebase Cloud Messaging
How to Record Video from Background of Application:Android
Unsigned APK Can Not Be Installed
Android - Build a Notification, Taskstackbuilder.Addparentstack Not Working
How to Handle the Firebase Notification When App Is in Foreground
How to Execute a Method by Clicking a Notification
Android Replace the Current Fragment with Another Fragment
How to Open Phones Gallery Through Code
Yet Another Getview Called Multiple Times
Adt Doesn't Create Default Hello World But Command Line Does