Hello,
Working on a new project with an incompatible colorAccent on the dark theme, I had to research how to dynamically change the color of colorAccent (Android) and I found the solution. If you see any error in this code that seems to be working fine, please let me know.
Best regards,
delaio.
MyApply.Android > Resources > values > colors.xml
<resources>
<color name="colorAccent">#000000</color>
<color name="colorAccentDark">#FFFFFF</color>
</resources>
MyApply.Android > Resources > values > styles.xml
<resources>
<style name="MainTheme" parent="MainTheme.Base">
<item name="colorAccent">@color/colorAccent</item>
</style>
<style name="NightTheme" parent="MainTheme.Base">
<item name="colorAccent">@color/colorAccentDark</item>
</style>
</resources>
MyApply.Android > MainActivity.cs
public override void OnConfigurationChanged(Configuration newConfig)
{
base.OnConfigurationChanged(newConfig);
if (Xamarin.Forms.Application.Current.RequestedTheme == OSAppTheme.Dark)
{
this.SetTheme(Resource.Style.NightTheme);
}
else
{
this.SetTheme(Resource.Style.MainTheme);
}
}
https://stackoverflow.com/questions/64256678/dynamically-change-androids-accent-color
https://developer.android.com/guide/topics/ui/look-and-feel/darktheme#config-changes