Android 如何在xamarin表单中更改导航栏文本颜色
我正在使用Xamarin表单,我想在Android中更改导航栏的颜色。 我正在使用这个代码:Android 如何在xamarin表单中更改导航栏文本颜色,android,xamarin,xamarin.android,xamarin.forms,Android,Xamarin,Xamarin.android,Xamarin.forms,我正在使用Xamarin表单,我想在Android中更改导航栏的颜色。 我正在使用这个代码: MainPage=新建导航页面 { BarBackgroundColor=颜色。石灰, BarTextColor=颜色。紫色 }; 第一个属性(BarBackgroundColor)已工作,第二个属性未工作(BarTextColor) 请回答我。如果您试图在Android 5.0或更高版本上设置文本颜色,则需要设置MainActivity的主题。这里有一个简单的,应该工作 [Activity(
MainPage=新建导航页面
{
BarBackgroundColor=颜色。石灰,
BarTextColor=颜色。紫色
};代码>
第一个属性(BarBackgroundColor
)已工作,第二个属性未工作(BarTextColor
)
请回答我。如果您试图在Android 5.0或更高版本上设置文本颜色,则需要设置MainActivity
的主题。这里有一个简单的,应该工作
[Activity(
Label = "Some App Title",
Icon = "@drawable/icon",
MainLauncher = true,
Theme = "@style/android:Theme.Holo.Light"
)]
您可以在app.xaml中设置,它将覆盖它
它将更改yourPage()
bar颜色仅在app.xaml中设置这些属性将可靠地完成这项工作
<Style TargetType="NavigationPage">
<Setter Property="BarBackgroundColor" Value="Red"/>
<Setter Property="BarTextColor" Value="White"/>
</Style>
</ResourceDictionary>
var page = new navigationPage(new yourPage());
page.BarBackgroundColor = Color.FromHex("#123456");