I want to change the color of the ToolbarItem
and the overflow button (3 vertical dots). As I have found out the colorPrimaryDark
is responsible for both. If I change the color also the color of the dots or ToolbarItem
text color changes. But changing colorPrimaryDark
leads to modifications in my generall app for all sorts of elements.
How do I change the color specifically for the items in the ActionBar
?
Here I define AppTheme for my app in MainActivity.cs:
[Activity(Theme = "@style/AppTheme", ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)]
public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsApplicationActivity
{
// ...
}
In themes_apptheme.xml under Resources/values I have defined my AppTheme:
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<style name="AppTheme" parent="android:Theme.Material.Light">
<!-- ... -->
<item name="android:colorPrimaryDark">@color/primaryDark</item>
<item name="android:textColorPrimary">@color/primaryDark</item>
<item name="android:actionBarStyle">@style/MyActionBarTheme</item>
</style>
</resources>
In styles.xml under Resources/values there is the referenced MyActionBarTheme:
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<style name="MyActionBarTheme" parent="@android:style/Widget.Holo.Light.ActionBar">
<item name="android:homeAsUpIndicator">@drawable/ic_back</item>
<!--<item name="android:background">@color/primaryDark</item>-->
<item name="android:textColorPrimary">@color/white</item>
<item name="android:actionMenuTextColor">@color/white</item>
<item name="android:actionModeBackground">@color/primaryDark</item>
</style>
</resources>
I've tried the solutions from the similar questions (e.g. textColorSecondary
), but non of them worked or specifically targets my needs. For the dots an image could be used, but that doesn't change the color of ToolbarItem
and seems not to be necessary. Also other solutions are using the newer Toolbar
instead of the ActionBar
. Furthermore the themes are different. Can I somehow use a custom renderer? Or would it be sufficient to add one item to my style? Which one is it?
PS: I'm using Xamarin.Forms 2.5.0.121934
Edit:
My goal is to have a white color for the overflow button and the ToolbarItem
text. This can be achived, if I use the following:
<style name="AppTheme" parent="android:Theme.Material.Light.DarkActionBar">
<!-- ... -->
</style>
The downside of this approach is, that the background of ContextAction
is black and I don't know how to change the color (as before with the dots and the toolbar button). Styling in Android is a big hassle for me.