xamarin表单-操作栏颜色
如何更改操作栏的颜色并恢复水平线 我有一个成功的android应用程序,是用原生的xamarin android开发的。现在我尝试使用xaml方法将其移植到Xamarin表单 我创建了一个hello world应用程序,并在contentPage中添加了一个工具栏项。当我最初启动应用程序时,可以看到带有我的图标的操作栏,正常的蓝绿色背景,还有一条漂亮的水平线。然而,一旦我的表单代码启动,它就会显示我的图标,我的工具栏项目图标,但背景是黑色的,没有水平线 我试过NavigationPage.BackgroundColor,但没有效果。我在想我做错了什么 这是我的xamlxamarin表单-操作栏颜色,xamarin,colors,xamarin.forms,Xamarin,Colors,Xamarin.forms,如何更改操作栏的颜色并恢复水平线 我有一个成功的android应用程序,是用原生的xamarin android开发的。现在我尝试使用xaml方法将其移植到Xamarin表单 我创建了一个hello world应用程序,并在contentPage中添加了一个工具栏项。当我最初启动应用程序时,可以看到带有我的图标的操作栏,正常的蓝绿色背景,还有一条漂亮的水平线。然而,一旦我的表单代码启动,它就会显示我的图标,我的工具栏项目图标,但背景是黑色的,没有水平线 我试过NavigationPage.Bac
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage.Title> My Sample </ContentPage.Title>
<ContentPage.ToolbarItems>
<ToolbarItem Name="test" Icon="ic_action_refresh" ></ToolbarItem>
</ContentPage.ToolbarItems>
<Label Text="Hello Forms" VerticalOptions="Center" HorizontalOptions="Center" />
</ContentPage>
我还想在启动时隐藏默认的actionbar,并使用一个完整的启动屏幕,但我确实发现这个线程看起来可以工作 我明白了。我在VS2013中使用的是默认模板,Xamarin.Forms.Core库参考是1.0版。自那以后,已经有一些更新,其中一个修复了这个问题。我刚刚通过nuget更新到最新版本,它开始工作。我找到了答案。我在VS2013中使用的是默认模板,Xamarin.Forms.Core库参考是1.0版。自那以后,已经有一些更新,其中一个修复了这个问题。我刚刚通过nuget更新到最新版本,它开始工作。在生成导航页面时,我很幸运地使用了以下方法,其中键是BarBackgroundColor属性,键是设置栏本身颜色的键。底层边界也应该仍然存在。您还可以使用任何您喜欢的颜色方法,而不仅仅是FromHex方法
private Page GetNavigationPage(Page innerPage){
var navigation = new NavigationPage (innerPage);
navigation.BarBackgroundColor= Color.FromHex ("#00263A");
return navigation;
}
在生成NavigationPage时,我很幸运地使用了以下方法,其中键是BarBackgroundColor属性,键是设置栏本身颜色的键。底层边界也应该仍然存在。您还可以使用任何您喜欢的颜色方法,而不仅仅是FromHex方法
private Page GetNavigationPage(Page innerPage){
var navigation = new NavigationPage (innerPage);
navigation.BarBackgroundColor= Color.FromHex ("#00263A");
return navigation;
}
这就是我所做的 在App.xaml中,添加以下行,它可以在iOS和Android中运行
<Style TargetType="NavigationPage">
<Setter Property="BarBackgroundColor" Value="whatever color value here"/>
</Style>
这就是我所做的 在App.xaml中,添加以下行,它可以在iOS和Android中运行
<Style TargetType="NavigationPage">
<Setter Property="BarBackgroundColor" Value="whatever color value here"/>
</Style>
尝试在App.xaml.cs上执行此操作
MainPage = new NavigationPage(new TrainPage());
((NavigationPage)Application.Current.MainPage).BarBackgroundColor = Color.Black;
((NavigationPage)Application.Current.MainPage).BarTextColor = Color.White;
请尝试在App.xaml.cs上执行此操作
MainPage = new NavigationPage(new TrainPage());
((NavigationPage)Application.Current.MainPage).BarBackgroundColor = Color.Black;
((NavigationPage)Application.Current.MainPage).BarTextColor = Color.White;
尝试设置NavigationPage.BarBackgroundColor尝试设置NavigationPage.BarBackgroundColor