简体   繁体   English

如何在xamarin表单android中更改导航栏文本颜色

[英]How to change navigation bar text color in xamarin forms android

Im using Xamarin Forms and i want to change color of Navigationbar in Android. 我使用Xamarin Forms,我想改变Android中Navigationbar的颜色。 Im using this code: 我使用这段代码:

MainPage = new NavigationPage { BarBackgroundColor = Color.Lime, BarTextColor = Color.Purple };

The first property ( BarBackgroundColor ) was worked, second property not worked ( BarTextColor ). 第一个属性( BarBackgroundColor )工作,第二个属性不起作用( BarTextColor )。

Please kindly answer me. 请好好回答我。

If you are trying to set the text color on Android 5.0 or higher, you need to set the Theme of the MainActivity . 如果您尝试在Android 5.0或更高版本上设置文本颜色,则需要设置MainActivityTheme Here is a simple one that should work... 这是一个应该工作的简单...

[Activity(
    Label = "Some App Title", 
    Icon = "@drawable/icon", 
    MainLauncher = true, 
    Theme = "@style/android:Theme.Holo.Light"
)]

you can set in your app.xaml and it will override it 您可以在app.xaml中进行设置,它将覆盖它

  <Style TargetType="NavigationPage">
    <Setter Property="BarBackgroundColor" Value="Red"/>
    <Setter Property="BarTextColor" Value="White"/>
  </Style>


</ResourceDictionary>

在app.xaml中设置这些属性只能可靠地完成工作!

var page = new navigationPage(new yourPage());
page.BarBackgroundColor = Color.FromHex("#123456");

It will change yourPage() bar color 它将更改yourPage()栏颜色

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

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