Xaml 如何更改底部工具栏页面中的工具栏背景色
Hy,我是Xamarin表单的新手,我正在使用BottomBarPage,现在我需要一个带有不同项目的自定义工具栏,正如您在代码中看到的那样,我成功地添加了一个ToolbarItem,我的疑问是,如何更改工具栏的背景色?我尝试在xf:BottomBarPage中使用x:BackgroundColor,但没有成功。有什么建议吗Xaml 如何更改底部工具栏页面中的工具栏背景色,xaml,xamarin.forms,toolbar,bottombar,Xaml,Xamarin.forms,Toolbar,Bottombar,Hy,我是Xamarin表单的新手,我正在使用BottomBarPage,现在我需要一个带有不同项目的自定义工具栏,正如您在代码中看到的那样,我成功地添加了一个ToolbarItem,我的疑问是,如何更改工具栏的背景色?我尝试在xf:BottomBarPage中使用x:BackgroundColor,但没有成功。有什么建议吗 <?xml version="1.0" encoding="utf-8" ?> <xf:BottomBarPage xmlns="http://xamar
<?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>
蓝色条是我要更改的背景色
现在使用TabbedPage,声明如下:
但是顶部酒吧的颜色仍然是蓝色,我怎么能改变它呢?
正如@fabriBertani所说,
使用官方标签页和底部标签规范,如他分享的文章中所述,检查下面我分享的代码
<TabbedPage
xmlns ="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:test="clr-namespace:Test;assembly=Test"
xmlns:android="clr-namespace:Xamarin.Forms.PlatformConfiguration.AndroidSpecific;assembly=Xamarin.Forms.Core"
android:TabbedPage.ToolbarPlacement="Bottom"
BarBackgroundColor="Red"
x:Class="Test.TabbedPage">
<test:MainPage Title="Page 1" Icon="alarm"/>
<test:MainPage Title="Page 2" Icon="watch"/>
</TabbedPage>
考虑到@FabriBertani给你的答案,没有什么可补充的 考虑到工具栏,Xamarin.Forms不支持iOS工具栏,如果你想写一些完全一样的东西,你可能需要自己做很多工作,在这种情况下最好使用Xamarin.iOS+Xamarin.Android 如果你想要Xamari.Forms没有简单的解决方案,需要很高的技能水平和大量的时间,因此几乎没有更好的答案-没有人会为您这样做,我不确定您的技能是否符合要求的水平,即使他们符合要求,也可能是浪费时间在这样的事情上,而不是使用其他方法 转到你的App.xaml.cs 在主页面中初始化组件之后
这将更改工具栏项目的背景色。简单 看起来你使用的是一个过时的库,你现在可以在XF上这样做了,按照这篇文章:@FabriBertani我在跨平台iOS&Android做Android中的官方标签页在顶部,iOS中在底部,我使用BarBottomPage将两者都放在底部。我的问题是,如何编辑工具栏,如图中蓝色条所示@Ahmad Elmadi最近他们开始支持Android中的底部栏,只要遵循我给你的代码就可以了。注意
BarBackgroundColor
我更改了它,现在我在底部有条,但我仍然在顶部有工具条,我是蓝色的,正如你在图片中看到的那样,我如何更改它?
public App()
{
InitializeComponent();
MainPage = new NavigationPage(new MainPage())
{
BarBackgroundColor = Color.Red
};
}
MainPage = new NavigationPage(new Login())
{
BarBackgroundColor = Color.DarkOrange
};