如何改善用户界面?首先,确认您使用的是最新版本的Xamarin.Forms,v2.3.2.127. iOS在iOS上,您可以通过设置Master页面的& ;;的Padding属性来模仿Detail页面的导航栏颜色.像这样将Master页面BackgroundColor属性设置为Color.Black:Master = new ContentPage{ BackgroundColor = Color.Black, Padding = new Thickness(0, Device.OnPlatform(64, 0, 0), 0, 0)}; Android在Android上,预期的行为是使Master页面从左侧滑入并覆盖Detail页面.要更新Android UI,我建议更新以下三个项目之一:Master.BackgroundColor属性,ListView.BackgroundColor属性或Master页面上ListView中使用的图标的颜色.如果您不希望导航栏向右移动,则可以在Android MainActivity类中扩展FormsApplicationActivity,这将阻止导航栏移动: public class MainActivity : Xamarin.Forms.Platform.Android.FormsApplicationActivity此示例显示,当您使用FormsApplicationActivity时,导航栏不会在Android应用程序上滑过: https://developer.xamarin.com/samples/xamarin-表格/导航/MasterDetailPage/ I'm trying to create a MasterDetailPage and I am not quite sure, if I am doing that right, but the drawer / master just looks ugly. For example, the navigation bar color is not showing, ...:Any ideas / tips on how to improve it? 解决方案 MasterDetailPage InformationBefore we jump into the answer, let's go over the MasterDetailPage class and how the MasterDetailPage is configured in your example.The MasterDetailPage class in Xamarin.Forms requires two Page properties:MasterDetailPage.Detail property needs to be set to a NavigationPage containing a ContentPage instance.MasterDetailPage.Master property needs to be set to a ContentPage instanceThe Detail page in your example is on the right side of the screen. The Detail page is a ContentPage inside of a NavigationPage with NavigationPage.BarBackgroundColor set to Color.Black. The ContentPage inside of this NavigationPage has ContentPage.BackgroundColor set to Color.Grey.The Master page in your example is on the left side of the screen. It is a ContentPage that contains a ListView. Without knowing your code, my guess is that the ContentPage.BackgroundColor is set to Color.White and the the ListView.BackgroundColor is not set.The Navigation Bar is being covered when you select the Navigation Drawer icon. This is happening because the Navigation Bar is on the Detail page, and not on the Master page.Answer To Your QuestionWhy is the Navigation Bar Color not showing on the Master page?The Master page can only be a ContentPage and it can not be inside of a NavigationPage, therefore it does not have a Navigation Bar (only a NavigationPage can have a Navigation Bar).How Can I Improve the UI?First, verify that you are on the latest version of Xamarin.Forms, v2.3.2.127.iOSOn iOS, you can mimic the Detail page's Navigation Bar color by setting the Padding property of the Master page & setting the Master page BackgroundColor property to Color.Black like so:Master = new ContentPage{ BackgroundColor = Color.Black, Padding = new Thickness(0, Device.OnPlatform(64, 0, 0), 0, 0)};AndroidOn Android, the expected behavior is to have the Master page slide in from the left and cover the Detail page. To update the Android UI, I recommend updating one of the three following items: the Master.BackgroundColor property, the ListView.BackgroundColor property or the color of the icons used in the ListView on the Master page.If you don't want the Navigation Bar to shift right, you can extend FormsApplicationActivity in the Android MainActivity class, which will prevent the Navigation Bar from moving:public class MainActivity : Xamarin.Forms.Platform.Android.FormsApplicationActivityThis sample shows that the NavigationBar does not slide over on an Android app when you use FormsApplicationActivity:https://developer.xamarin.com/samples/xamarin-forms/Navigation/MasterDetailPage/ 这篇关于Xamarin MasterDetailPage看起来很丑的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!