Aboobakkar P S
Aboobakkar P S

Reputation: 806

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. Im using this code:

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

The first property (BarBackgroundColor) was worked, second property not worked (BarTextColor).

Please kindly answer me.

Upvotes: 5

Views: 7370

Answers (4)

Pius Hodel
Pius Hodel

Reputation: 1

Setting those attributes in app.xaml only will reliably do the job!

Upvotes: 0

Gurveer Singh
Gurveer Singh

Reputation: 43

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

It will change yourPage() bar color

Upvotes: -1

Emil
Emil

Reputation: 6921

you can set in your app.xaml and it will override it

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


</ResourceDictionary>

Upvotes: 3

Ryan Alford
Ryan Alford

Reputation: 7594

If you are trying to set the text color on Android 5.0 or higher, you need to set the Theme of the MainActivity. Here is a simple one that should work...

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

Upvotes: 1

Related Questions