【发布时间】:2019-01-10 13:03:16
【问题描述】:
嗨,我是 Xamarin Forms 的新手,我正在使用 BottomBarPage,现在我需要一个包含不同项目的自定义工具栏,正如您在代码中看到的那样,我成功添加了 ToolbarItem,我的疑问是,我该怎么做更改工具栏背景颜色?我在 xf:BottomBarPage 中尝试了 x:BackgroundColor 但没有用。有什么建议吗?
<?xml version="1.0" encoding="utf-8" ?>
<xf:BottomBarPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="MyProject.Views.StartPage"
xmlns:xf="clr-namespace:BottomBar.XamarinForms;assembly=BottomBar.XamarinForms"
xmlns:Views="clr-namespace:MyProject.Views;assembly=MyProject"
x:Name="TabMenu">
<xf:BottomBarPage.ToolbarItems x:BackgroundColor="#D60000">
<ToolbarItem Name="User" Order="Primary" Icon="home.png" Text="Item 1" Priority="0" Clicked="User_Clicked"/>
<!--<ToolbarItem Name="MenuItem2" Order="Primary" Icon="Xamarin.png" Text="Item 2" Priority="1" />-->
</xf:BottomBarPage.ToolbarItems>
<xf:BottomBarPage.Children>
<Views:MainPage
ClassId="Home"
Title="Page1"
Icon="Page1.png"
xf:BottomBarPageExtensions.TabColor="#D60000"/>
<Views:MainPage
Title="Page2"
Icon="Page2.png"
xf:BottomBarPageExtensions.TabColor="#D60000"/>
<Views:Graphs
Title="Page3"
Icon="Page3.png"
xf:BottomBarPageExtensions.TabColor="#D60000"/>
<Views:MainPage
Title="Page4"
Icon="Page4.png"
xf:BottomBarPageExtensions.TabColor="#D60000"/>
<Views:Info
Title="Page5"
Icon="Page5.png"
xf:BottomBarPageExtensions.TabColor="#D60000"/>
</xf:BottomBarPage.Children>
</xf:BottomBarPage>
蓝色条是我要更改的背景颜色 Color ToolBar
现在使用 TabbedPage,声明是: Tabbed Page
但是顶部栏的颜色仍然是蓝色,我该如何更改? Top ToolBar
【问题讨论】:
-
看来您使用的库已经过时了,您现在可以在 XF 上执行此操作,请关注这篇文章:Official Bottom Navigation/Bottom Tabs on Android
-
@FabriBertani 我正在做跨平台的 iOS&Android
标签: xaml xamarin.forms toolbar bottombar