工具栏颜色默认为白色,我想将其更改为蓝色。我几乎可以改变一切,但不是。
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>
有两种可能的方法:
BarBackgroundColor
的BarTextColor
和NavigationPage
。在你的情况下,它会是这样的:MainPage = new NavigationPage(new YourPage())
{
BarBackgroundColor = Color.White,
BarTextColor = Color.Blue
};
android:textColorPrimary
android:textColorSecondary`,尝试类似的东西:<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>
我认为android:
可能是问题,因为我的行为与我说的完全一样,并且它正在发挥作用。
我找到了一种方法。它与我在那里读到的所有答案混合在一起。我使用了Change color of ToolBarItem in XAML @Guillermo Daniel Arias的回答。在styles.XML上
<item name="android:actionMenuTextColor">#1c4d9e</item>
在App.xaml上(在xamarin表单共享项目中)
<Style TargetType="NavigationPage">
<Setter Property="BarBackgroundColor" Value="White"/>
<Setter Property="BarTextColor" Value="#004895"/>
</Style>