簡體   English   中英

如何在xamarin表單android中更改導航欄文本顏色

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

我使用Xamarin Forms,我想改變Android中Navigationbar的顏色。 我使用這段代碼:

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

第一個屬性( BarBackgroundColor )工作,第二個屬性不起作用( BarTextColor )。

請好好回答我。

如果您嘗試在Android 5.0或更高版本上設置文本顏色,則需要設置MainActivityTheme 這是一個應該工作的簡單...

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

您可以在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");

它將更改yourPage()欄顏色

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM