微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

如何更改工具栏颜色?xamarin.forms

如何解决如何更改工具栏颜色?xamarin.forms

如何更改工具栏颜色?(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>

screen of app

解决方法

在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" />

enter image description here

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。