Set menu overflow icon to be white - android

I have a dummy app that I'm making just to get the hang of Android development. I managed to get a menu overflow icon to appear on my toolbar, but I can't seem to figure out how to change it to white.
I'm using a Toolbar widget (without support libraries; that's something I don't want to do).
Here is what I have:
I just want to make the overflow menu white.
styles.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="AppTheme" parent="android:Theme.Material.Light.DarkActionBar">
<item name="android:windowNoTitle">true</item>
<item name="android:windowActionBar">false</item>
<item name="android:colorPrimary">#color/primary</item>
<item name="android:colorPrimaryDark">#color/primary_dark</item>
<item name="android:colorAccent">#color/accent</item>
</style>

You want to change android:textColorSecondary like so:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="AppTheme" parent="android:Theme.Material.Light.DarkActionBar">
<item name="android:windowNoTitle">true</item>
<item name="android:windowActionBar">false</item>
<item name="android:colorPrimary">#color/primary</item>
<item name="android:colorPrimaryDark">#color/primary_dark</item>
<item name="android:colorAccent">#color/accent</item>
<!-- Here you go. This changes overflow icon colour. -->
<item name="android:textColorSecondary">#color/WHITE</item>
</style>

Just add android:theme="#style/ThemeOverlay.AppCompat.Dark" to the toolbar
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="#style/AppTheme.PopupOverlay"
android:theme="#style/ThemeOverlay.AppCompat.Dark"/>
This thing worked for me :)

<style name="AppThemeLL" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="android:windowActionBar">false</item>
<item name="android:windowNoTitle">true</item>
<item name="android:colorBackground">#color/white</item>
<item name="android:textColorSecondary">#color/white</item>
</style>

Related

Android changing text color on popup menu

In my app, when I click on the three dot button, menu items appear in white text color on white background. I wanted to change the text color to black but it doesn't work. I've looked for solutions but none of them worked.
Here's my code:
styles.xml
<resources>
<style name="AppMaterialTheme" parent="SuperMaterialTheme">
</style>
<!-- Base application theme. -->
<style name="SuperMaterialTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
</style>
<style name="SplashTheme" parent="Theme.AppCompat.NoActionBar">
<item name="android:windowBackground">#drawable/splash_background</item>
</style>
<style name="ToolbarTheme" parent="ThemeOverlay.AppCompat.Light">
<item name="android:textColorPrimary">#android:color/white</item>
<item name="android:textColorSecondary">#android:color/white</item>
</style>
<style name="PopupTheme" parent="ThemeOverlay.AppCompat.Light">
<item name="android:textColorPrimary">#000000</item>
</style>
Toolbar.xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/colorPrimary"
android:minHeight="?attr/actionBarSize"
android:theme="#style/ToolbarTheme"
app:popupTheme="#style/PopupTheme"
>
Where's the mistake? Thanks in advance
The menu you're asking for is called the Overflow Menu.You can change the color of the overflow menu background by adding a new style in style.xml.
<style name="OverflowMenu"
parent="#android:style/Theme.Holo">
<item name="android:popupMenuStyle">#style/MyOverflowMenu</item>
<item name="android:itemTextAppearance">#style/TextAppearance</item>
</style>
<style name="MyOverflowMenu"
parent="#android:style/Widget.Holo.ListPopupWindow">
<item name="android:popupBackground">#color/your_color</item>
</style>
<style name="TextAppearance">
<item name="android:textColor">#color/your_color</item>
</style>

Unable to change the Color of the Menu option on the Android Toolbar

been trying to change the color of the menu items that appear on the Toolbar.
Here is my menu xml
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="#+id/action_settings"
android:title="Settings"
app:showAsAction="never"
android:orderInCategory="100"/>
<item android:id="#+id/always"
android:title="Always"
app:showAsAction="always"
android:orderInCategory="101"/>
<item android:id="#+id/never"
android:title="Never"
app:showAsAction="never"
android:orderInCategory="102"/>
<item android:id="#+id/ifroom"
android:title="If Room"
android:orderInCategory="103"
app:showAsAction="ifRoom"/>
<item android:id="#+id/always1"
android:title="Always1"
app:showAsAction="always"
android:orderInCategory="104"/>
</menu>
styles.xml
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
<item name="actionMenuTextColor">#color/white</item>
<item name="android:actionMenuTextColor">#color/white</item>
</style>
</resources>
I've tried using the style options but I cannot figure out how to change the color. The actionMenuTextColor & android:actionMenuTextColor do not solve the problem. It still appears black. Which looks untidy on my blue background.
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_height="wrap_content"
android:layout_width="match_parent"
app:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:popupTheme="#style/ThemeOverlay.AppCompat.Light"
android:background="#color/colorPrimary">
</android.support.v7.widget.Toolbar>
Turns out I was inheriting the wrong theme! This works for me!
Remove this line in styles.xml
<item name="actionMenuTextColor">#color/white</item>
<item name="android:actionMenuTextColor">#color/white</item>
and add this
<item name="android:textColor">#color/red</item>
<item name="android:itemBackground">#color/skyBlue</item>
Complete code :
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
<item name="android:textColor">#color/red</item>
<item name="android:itemBackground">#color/skyBlue</item>
</style>

Change the text color of the popup menu

I am using Theme.AppCompat.Light.NoActionBar theme. I am getting a white background for popup menu and also the color of menu item is white that makes it invisible. I tried many solutions with no success.
This is my styles.xml
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:actionMenuTextColor">#000000</item>
<item name="android:textColorPrimary">#color/white</item>
<item name="android:textColorSecondary">#color/white</item>
<item name="android:popupMenuStyle">#style/PopupMenu</item>
<item name="android:textAppearanceLargePopupMenu">#style/myPopupMenuTextAppearanceLarge</item>
<item name="android:textAppearanceSmallPopupMenu">#style/myPopupMenuTextAppearanceSmall</item>
<!-- Customize your theme here. -->
</style>
<style name="PopupMenu" parent="#android:style/Widget.PopupMenu">
<item name="android:popupBackground">#android:color/white</item>
<item name="android:textColor">#000000</item>
<item name="android:textSize">12sp</item>
</style>
<style name="myPopupMenuTextAppearanceSmall" parent="#android:style/TextAppearance.DeviceDefault.Widget.PopupMenu.Small" tools:ignore="NewApi">
<item name="android:textColor">#000000</item>
<item name="android:textSize">15sp</item>
</style>
<style name="myPopupMenuTextAppearanceLarge" parent="#android:style/TextAppearance.DeviceDefault.Widget.PopupMenu.Large" tools:ignore="NewApi">
<item name="android:textColor">#000000</item>
<item name="android:textSize">25sp</item>
</style>
This is the toolbar
<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/toolbar"
android:elevation="8dp"
app:theme="#style/AppTheme"
app:title="Troll Cricket" />
Add these lines to your Toolbar.xml file.
app:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:popupTheme="#style/ThemeOverlay.AppCompat.Light"
This will allow you to have a dark toolbar and light-themed overflow menu.

Toolbar overflow menu items not highlighed properly

I have a problem that frustrates me a lot. I can't get to the end of it. The menu items in the overflow menu in the Toolbar of my Android app are not highlighted properly. That is, only the background outside of the text changes color when the button is pressed, while the background behind the text does not. Here's a screenshot:
http://imgur.com/gqE9xbl
I've found questions with this exact problem, but with no answers. Please help me.
Regards,
Aleksandar
UPDATE
Here's the source for my styles and the Toolbar:
<style name="BaseTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="colorPrimary">#color/converterColorPrimary</item>
<item name="colorPrimaryDark">#color/converterColorPrimaryDark</item>
<item name="colorAccent">#color/converterColorAccent</item>
<item name="android:windowActionBar">false</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowBackground">#color/converterWindowBackground</item>
<item name="android:textColor">#color/converterWindowTextColor</item>
<item name="colorControlNormal">#color/converterControlColorNormal</item>
<item name="colorControlHighlight">#color/converterColorControlHighlight</item>
</style>
<style name="AppTheme" parent="BaseTheme"/>
<style name="ToolbarThemeOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar">
<item name="android:background">#color/converterColorPrimary</item>
<item name="android:textColorPrimary">#color/converterToolbarTextColorPrimary</item>
</style>
<style name="ToolbarPopupTheme" parent="ThemeOverlay.AppCompat.Light">
<item name="android:background">#color/converterWindowBackground</item>
<item name="android:textColorPrimary">#color/converterWindowTextColor</item>
</style>
<style name="ToolbarTitleTextAppearance" parent="TextAppearance.AppCompat.Widget.ActionBar.Title">
<item name="android:textColor">#color/converterToolbarTextColorPrimary</item>
<item name="android:textSize">18sp</item>
</style>
Toolbar:
<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:converter="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="?attr/actionBarSize"
android:id="#+id/app_bar"
converter:theme="#style/ToolbarThemeOverlay"
converter:popupTheme="#style/ToolbarPopupTheme"
converter:titleTextAppearance="#style/ToolbarTitleTextAppearance"/>

Appcombat v7 Toolbar with drawer changing colors

I am implementing material design on my app, and I want to be able to change the color of the drawer icon to white, but I couldnt achieve what I am looking for..
This is my themes.xml file:
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<style name="AppTheme" parent="AppTheme.Base" />
<style name="AppTheme.Base" parent="Theme.AppCompat.Light">
<item name="colorPrimary">#color/primary</item>
<item name="colorPrimaryDark">#color/primary_dark</item>
<item name="android:windowNoTitle">true</item>
<item name="windowActionBar">false</item>
</style>
<style name="HeaderBar" parent="AppTheme.Base">
<item name="android:textColorPrimary">#android:color/white</item>
<item name="android:background">#color/primary</item>
<item name="actionMenuTextColor">#android:color/white</item>
<item name="android:textColorSecondary">#android:color/white</item>
<item name="android:actionMenuTextColor">#android:color/white</item>
</style>
<style name="ActionBarPopupThemeOverlay" parent="ThemeOverlay.AppCompat.Light">
<item name="android:background">#android:color/white</item>
<item name="android:textColor">#000</item>
</style>
<style name="ActionBarThemeOverlay" parent="">
<item name="android:textColorPrimary">#fff</item>
<item name="colorControlNormal">#fff</item>
<item name="colorControlHighlight">#3fff</item>
</style>
</resources>
And this is my toolbar.xml file
<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res/jpe.serviguide.commobile"
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorPrimary"
app:popupTheme="#style/ActionBarPopupThemeOverlay"
app:theme="#style/HeaderBar" />
All the colors that I wanted are just fine, but the drawer icon is black instead of white..
I have tried a lot of thing but with no desire result
Thank you so much
Finally made it by doing this on my theme.xml file
<style name="AppTheme" parent="Theme.AppCompat.Light">
....
<item name="drawerArrowStyle">#style/DrawerArrowStyle</item>
</style>
<style name="DrawerArrowStyle" parent="Widget.AppCompat.DrawerArrowToggle">
<item name="spinBars">true</item>
<item name="color">#android:color/white</item>
</style>
You can do it like this:
<android.support.v7.widget.Toolbar
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/colorPrimaryDark"
android:minHeight="?attr/actionBarSize"
app:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar" />
app:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar" - is important part
I think your actionbar should have the following parent (ThemeAppCompat.Light):
<style name="HeaderBar" parent="Theme.AppCompat.Light">
<item name="android:textColorPrimary">#android:color/white</item>
<item name="android:background">#color/primary</item>
<item name="actionMenuTextColor">#android:color/white</item>
<item name="android:textColorSecondary">#android:color/white</item>
<item name="android:actionMenuTextColor">#android:color/white</item>
</style>
Hi neteot always when I work with costume bars I create a custom layout as a bar, then in my case the bars button/burguer button is a ImageButton... Then you need to change color of the icon
If you want to create a perfect custom bar, u can see my last post:
https://stackoverflow.com/questions/27417923/android-add-custom-buttons-on-action-bar/27418306#27418306
Good luck and I wait than I helps you!!
PD: If you need more info or any doubt, advice me!

Categories

Resources