简体   繁体   English

更改android中后退按钮的颜色

[英]Change color of back button in android

Cannot change the color of my back button in android.无法在 android 中更改后退按钮的颜色。 In ios, is working very well.在ios中,运行良好。

((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.正如您在此处看到的,它目前不受支持,并且在 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在你的 Android 项目Resources/layout/styles.xml 中添加 ToolbarTheme 样式

<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然后将android:theme="@style/ToolbarTheme"Resources/layout/Toolbar.axml 中的工具栏

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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