Reputation: 555
The toolbar color is by default white and I would like to change it to blue. I was able to change almost everything but not that.
Toolbar.axml
<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorPrimary"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
android:popupTheme="@style/ThemeOverlay.AppCompat.Light" />
styles.xml
<style name="MyTheme.Base" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="android:textColorPrimary">#1b2b32</item>
<item name="android:textColorSecondary">#1c4d9e</item>
Upvotes: 5
Views: 7464
Reputation: 660
in App.xml add this :
<Application.Resources>
<ResourceDictionary>
<Color x:Key="mRed">#65508F</Color>
<Color x:Key="mWhite">#FFFFFF</Color>
<Style TargetType="NavigationPage">
<Setter Property="BarBackgroundColor" Value="{StaticResource mRed}" />
<Setter Property="BarTextColor" Value="{StaticResource mWhite}" />
</Style>
</ResourceDictionary>
</Application.Resources>
Upvotes: 0
Reputation: 676
There are two possible approaches:
BarBackgroundColor
and BarTextColor
of your NavigationPage
. In your case, it would be something like that:MainPage = new NavigationPage(new YourPage())
{
BarBackgroundColor = Color.White,
BarTextColor = Color.Blue
};
android:textColorPrimary
android:textColorSecondary`, try something like that: <style name="MyTheme.Base" parent="Theme.AppCompat.Light.NoActionBar">
<item name="colorPrimary">#FFFFFF</item>
<item name="colorSecondary">#0000FF</item>
<item name="colorAccent">#0000FF</item>
</style>
I think that android:
may be the problem, because I'm doing exactly like I said and it's working.
Upvotes: 2
Reputation: 555
I found an approach. it is mixed with all the answers I read out there. I used this answer from Change color of ToolBarItem in XAML @Guillermo Daniel Arias. on styles.XML
<item name="android:actionMenuTextColor">#1c4d9e</item>
on App.xml (On xamarin forms share project)
<Style TargetType="NavigationPage">
<Setter Property="BarBackgroundColor" Value="White"/>
<Setter Property="BarTextColor" Value="#004895"/>
</Style>
Upvotes: 8