屏幕显示被下推xamarin.forms android [英] Display of screen is pushed down xamarin.forms android
本文介绍了屏幕显示被下推xamarin.forms android的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
奇怪的是,我的屏幕显示仅在MainPage上被按下,然后显示才适合屏幕.我尝试删除该页面并重新添加它,但这也不起作用.有谁知道这可能是什么原因以及如何解决?
Weirdly my display of screen is pushed down for only the MainPage thereafter display fits the screen as it should. I've tried deleting the page and re-adding it but that didn't work either. Does anyone know what could be causing this and how to fix it?
外观如下:顶部的黑色空间不应存在
MainPage.xaml
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage
x:Class="LoyaltyWorx.Views.MainPage"
xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:LoyaltyWorx.Views.Converters"
xmlns:prism="clr-namespace:Prism.Mvvm;assembly=Prism.Forms"
prism:ViewModelLocator.AutowireViewModel="True"
>
<ContentPage.Resources>
<ResourceDictionary>
<local:InvertBooleanConverter x:Key="InvertBooleanConverter" />
</ResourceDictionary>
</ContentPage.Resources>
<Grid>
<Image Source="bk3.jpg" Aspect="AspectFill"/>
<StackLayout VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand">
<StackLayout Orientation="Horizontal" VerticalOptions="Start">
<!-- top controls -->
</StackLayout>
<StackLayout VerticalOptions="CenterAndExpand">
<!-- middle controls -->
<BoxView HeightRequest="430"></BoxView>
<Button Text="Continue with Facebook" x:Name="LoginBtn" BackgroundColor="#4867aa" TextColor="White" FontFamily="Klavika" HorizontalOptions="CenterAndExpand" Clicked="LoginBtn_Clicked" />
<Button Text="Continue with Google " Command="{Binding GoogleLoginCommand}" BackgroundColor="#d34836" TextColor="White" FontFamily="Klavika" HorizontalOptions="CenterAndExpand"/>
</StackLayout>
<StackLayout Orientation="Horizontal" VerticalOptions="End" HorizontalOptions="Center">
<!-- bottom controls -->
<Frame OutlineColor="White" HorizontalOptions="StartAndExpand">
<StackLayout Orientation="Horizontal" VerticalOptions="End" HorizontalOptions="Center">
<!-- bottom controls -->
<StackLayout Grid.Row="1" Orientation="Horizontal" Spacing="0">
<Label
Text="Terms and conditions"
FontSize="13"
TextColor="#71757a"
FontAttributes="Bold"
x:Name="LblTerms"/>
<Label
Text=" and"
FontSize="13"
TextColor="#71757a"
/>
<Label
Text=" privacy policy"
FontSize="13"
TextColor="#71757a"
FontAttributes="Bold"
x:Name="LblPrivacy"/>
</StackLayout>
</StackLayout>
</Frame>
</StackLayout>
</StackLayout>
</Grid>
</ContentPage>
App.cs
public partial class App : PrismApplication
{
public App(IPlatformInitializer initializer = null) : base(initializer) { }
protected override void OnInitialized()
{
InitializeComponent();
SetMainPage();
NavigationService.NavigateAsync("NavigationPage/MainPage?title=Hello%20from%20Xamarin.Forms");
}
protected override void RegisterTypes()
{
Container.RegisterTypeForNavigation<NavigationPage>();
Container.RegisterTypeForNavigation<MainPage>();
}
private void SetMainPage()
{
if (!string.IsNullOrEmpty(Helpers.Settings.Usertoken))
{
Application.Current.MainPage = (new Profile());
}
else
{
MainPage = new NavigationPage(new MainPage())
{ BarBackgroundColor = Color.FromHex("#393b3d") };
}
}
public async static Task NavigateToSMS()
{
await Application.Current.MainPage.Navigation.PushAsync(new SMS());
}
public static void NavigateToProfile()
{
Application.Current.MainPage = (new InvalidLogin());
}
public static void NavigateToVerified()
{
Application.Current.MainPage = (new Profile());
}
protected override void OnStart()
{
// Handle when your app starts
}
protected override void OnSleep()
{
// Handle when your app sleeps
}
protected override void OnResume()
{
// Handle when your app resumes
}
}
推荐答案
您将MainPage
包裹在NavigationPage
中,默认情况下会显示NavigationBar.您可以在CS代码或MainPage.xaml
You have your MainPage
wrapped in a NavigationPage
that by default shows the NavigationBar. You can turn it off in your cs code or in your MainPage.xaml
cs
var mainPage = new MainPage();
MainPage = new NavigationPage(mainPage);
NavigationPage.SetHasNavigationBar(mainPage, false);
xaml
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage
x:Class="LoyaltyWorx.Views.MainPage"
xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:LoyaltyWorx.Views.Converters"
xmlns:prism="clr-namespace:Prism.Mvvm;assembly=Prism.Forms"
prism:ViewModelLocator.AutowireViewModel="True"
NavigationPage.HasNavigationBar="False">
这篇关于屏幕显示被下推xamarin.forms android的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文