问题描述
如何更改工具栏颜色?(xamarin.forms) 如何将蓝色变为绿色?
<TabbedPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:pages="clr-namespace:News.Pages"
x:Class="News.MainPage"
BarBackgroundColor="Green">
<TabbedPage.toolbaritems>
<ToolbarItem x:Name="btnSetting" Text="Setting" IconImageSource="Setting.png" Clicked="btnSetting_Clicked"/>
</TabbedPage.toolbaritems>
<TabbedPage.Children>
<pages:WorldPage Title="World" IconImageSource="world.png"/>
<pages:TeredingPage Title="Trending" IconImageSource="trending.png"/>
<pages:GamePage Title="Game" IconImageSource="xBox.png"/>
</TabbedPage.Children>
</TabbedPage>
解决方法
在Android Resource/Layout/Toolbar xaml中,有一个属性
android:background="?attr/colorPrimary"
更改背景属性,如以下代码:
<android.support.v7.widget.Toolbar
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#ff99cc00"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
android:popupTheme="@style/ThemeOverlay.AppCompat.Light" />