【问题标题】:How to change navigation bar text color in xamarin forms android如何在xamarin表单android中更改导航栏文本颜色
【发布时间】:2016-06-14 11:45:46
【问题描述】:
我正在使用 Xamarin 表单,我想更改 Android 中导航栏的颜色。
我正在使用此代码:
MainPage = new NavigationPage
{
BarBackgroundColor = Color.Lime,
BarTextColor = Color.Purple
};
第一个属性 (BarBackgroundColor) 有效,第二个属性无效 (BarTextColor)。
请回答我。
【问题讨论】:
标签:
android
xamarin
xamarin.android
xamarin.forms
【解决方案1】:
你可以在你的 app.xaml 中设置它会覆盖它
<Style TargetType="NavigationPage">
<Setter Property="BarBackgroundColor" Value="Red"/>
<Setter Property="BarTextColor" Value="White"/>
</Style>
</ResourceDictionary>
【解决方案2】:
如果您尝试在 Android 5.0 或更高版本上设置文本颜色,则需要设置 MainActivity 的 Theme。这是一个应该可以工作的简单...
[Activity(
Label = "Some App Title",
Icon = "@drawable/icon",
MainLauncher = true,
Theme = "@style/android:Theme.Holo.Light"
)]
【解决方案3】:
仅在 app.xaml 中设置这些属性才能可靠地完成这项工作!
【解决方案4】:
var page = new navigationPage(new yourPage());
page.BarBackgroundColor = Color.FromHex("#123456");
它将改变yourPage()条形颜色