简体   繁体   中英

Change color of back button in android

Cannot change the color of my back button in android. In ios, is working very well.

((NavigationPage)Application.Current.MainPage).BackgroundColor = (Color)App.Current.Resources["white"];
((NavigationPage)Application.Current.MainPage).BarBackgroundColor = (Color)App.Current.Resources["white"];
((NavigationPage)Application.Current.MainPage).BarTextColor = (Color)App.Current.Resources["texto"];

Expected: back button color black.

Actual result: back button color white.

As you can see here , it currently isn't supported and there is an issue open on GitHub. For now, you should use a custom renderer or define a theme in your styles.

Add a ToolbarTheme style in your Android project Resources/layout/styles.xml

<style name="ToolbarTheme" parent="ThemeOverlay.AppCompat.Light">
    <item name="colorControlNormal">@android:color/black</item>
</style>

Then add android:theme="@style/ToolbarTheme" to your Toolbar in Resources/layout/Toolbar.axml

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM