I'm doing an Android app through Xamarin and I have a problem that I really can't figure out. I've set the Toolbar to use the Theme.Material.Light.DarkActionBar with white text on the toolbar. The toolbar contains also the Up arrow and an action icon, both white.
When I debug the app on emulators, it works fine, with the correct colors. When I debug on a old Note3 running Android 5.0, it works fine too. When I debug on a S7Edge running 8.0 or a J7 running 7.1 the toolbar title stays black, regardless of any change. The Up arrow and the icon stay white! I can't understand what is wrong and why the behavior is different.
styles.xml (here I've tried to force the white color)
<resources>
<style name="HomeTheme" 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:textColor">@color/primary_text</item>
</style>
<style name="ToolbarTheme" parent="android:ThemeOverlay.Material.Dark.ActionBar">
<item name="android:textColorPrimary">#ffffff</item>
<item name="android:textColorSecondary">#ffffff</item>
</style>
</resources>
All colors are varieties of blue, except primary_text which is black. The toolbar blue is always displayed correctly.
toolbar.axml
<?xml version="1.0" encoding="utf-8" ?>
<Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="?android:attr/actionBarSize"
android:background="?android:attr/colorPrimary"
android:theme="@style/ToolbarTheme"/>
The toolbar is included in the layout
<include
android:id="@+id/toolbar"
layout="@layout/toolbar" />
and it is called in the OnCreate method
SetContentView(Resource.Layout.mylayout);
var toolbar = FindViewById<Toolbar>(Resource.Id.toolbar);
SetActionBar(toolbar);
ActionBar.Title = "Title";
ActionBar.SetDisplayHomeAsUpEnabled(true);
ActionBar.SetHomeButtonEnabled(true);
The HomeTheme is applied to the whole app (it's written in the manifest). I've also tried to derive from AppCompat theme instead of Material but the result is the same. The app is compiled for API27 and the minimum requirement is API21. I've tried emulators running all supported API images, without any problem.