Xaml 在网格布局中,当键盘在xamarin.forms中打开时,如何滚动页面?
我在xamarin.forms中面临一个问题。我正在使用GridView进行登录页面设计,以便可以相应地更改设备的高度和宽度。我不想滚动那个页面,所以我没有放任何滚动视图 Xaml设计代码:-Xaml 在网格布局中,当键盘在xamarin.forms中打开时,如何滚动页面?,xaml,xamarin,xamarin.ios,xamarin.android,xamarin.forms,Xaml,Xamarin,Xamarin.ios,Xamarin.android,Xamarin.forms,我在xamarin.forms中面临一个问题。我正在使用GridView进行登录页面设计,以便可以相应地更改设备的高度和宽度。我不想滚动那个页面,所以我没有放任何滚动视图 Xaml设计代码:- <?xml version="1.0" encoding="utf-8" ?> <custom:KeyboardResizingAwareContentPage xmlns="http://xamarin.com/schemas/2014/forms" xmln
<?xml version="1.0" encoding="utf-8" ?>
<custom:KeyboardResizingAwareContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="HRMS.Login.LoginPage"
BackgroundImage="login_bg.png"
xmlns:local="clr-namespace:HRMS;assembly=HRMS"
Title="{x:Static local:AppResources.TitleLogin}"
xmlns:custom="clr-namespace:HRMS.Login;assembly=HRMS">
<ContentPage.Padding>
<OnIdiom x:TypeArguments="Thickness" Phone="60,40,60,40" Tablet="120,100,120,100" />
</ContentPage.Padding>
<custom:KeyboardResizingAwareContentPage.Resources>
<ResourceDictionary>
<Style x:Key="SubTitleStyle" TargetType="Label">
<Setter Property="FontSize" Value="Small" />
<Setter Property="FontAttributes" Value="Bold" />
<Setter Property="TextColor" Value="White" />
</Style>
</ResourceDictionary>
</custom:KeyboardResizingAwareContentPage.Resources>
<custom:KeyboardResizingAwareContentPage.Content>
<AbsoluteLayout x:Name="AbsMain">
<Grid VerticalOptions="Center" AbsoluteLayout.LayoutFlags="All" AbsoluteLayout.LayoutBounds="0,0,1,1">
<Grid.RowDefinitions>
<RowDefinition Height="35*"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="6*"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="6*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Image x:Name="ImgLogo" Source="login_logo.png" HorizontalOptions="Center" Grid.Row="0"/>
<StackLayout Grid.Row="1">
<StackLayout.HeightRequest>
<OnIdiom x:TypeArguments="x:Double" Tablet="55" Phone="35" />
</StackLayout.HeightRequest>
</StackLayout>
<Frame OutlineColor="#DCDCDC"
HorizontalOptions="FillAndExpand" VerticalOptions="Center"
HasShadow="false" Padding="1"
Grid.Row="2"
BackgroundColor="White"
Margin="5,0,5,0">
<Frame.HeightRequest>
<OnIdiom x:TypeArguments="x:Double" Tablet="55" Phone="35" />
</Frame.HeightRequest>
<Frame.Content>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="9*"/>
</Grid.ColumnDefinitions>
<Image x:Name="ImgLoginName" Grid.Column="0" Source="ico_login_name.png"
HorizontalOptions="StartAndExpand" VerticalOptions="Center" Margin="5,0,0,0"/>
<StackLayout Grid.Column="1" VerticalOptions="Center">
<Entry x:Name="TxtUsername" TextColor="#f15a23"
Margin="5,0,0,0"
PlaceholderColor="#8c8c8c"
BackgroundColor="White"
Placeholder="{x:Static local:AppResources.PHEmployeeCode}" />
</StackLayout>
</Grid>
</Frame.Content>
</Frame>
<Frame OutlineColor="#DCDCDC"
HorizontalOptions="FillAndExpand" VerticalOptions="Center"
HasShadow="false" Padding="1"
Grid.Row="3"
BackgroundColor="White"
Margin="5,0,5,0">
<Frame.HeightRequest>
<OnIdiom x:TypeArguments="x:Double" Tablet="55" Phone="35" />
</Frame.HeightRequest>
<Frame.Content>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="9*"/>
</Grid.ColumnDefinitions>
<Image x:Name="ImgLoginPassword" Grid.Column="0" Source="ico_login_password.png"
HorizontalOptions="StartAndExpand" VerticalOptions="Center" Margin="5,0,0,0"/>
<StackLayout Grid.Column="1" VerticalOptions="Center">
<Entry x:Name="TxtPassword" IsPassword="True" TextColor="#f15a23"
PlaceholderColor="#8c8c8c"
Margin="5,0,0,0"
BackgroundColor="White"
Placeholder="{x:Static local:AppResources.PHPassword}" />
</StackLayout>
</Grid>
</Frame.Content>
</Frame>
<Label x:Name="LblForgotPassword" Grid.Row="4" Margin="5,0,5,0"
Text="Forgot Password?" TextColor="Black" HorizontalTextAlignment="End"/>
<Button x:Name="BtnLogin" Text="{x:Static local:AppResources.BLogin}" Clicked="LoginButton_Clicked"
Grid.Row="5" BackgroundColor="#f15a23" TextColor="White"
HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand">
<Button.HeightRequest>
<OnIdiom x:TypeArguments="x:Double" Tablet="55" Phone="45" />
</Button.HeightRequest>
</Button>
<Image x:Name="ImgOr" Grid.Row="6" HorizontalOptions="FillAndExpand"
Source="or.png" />
<Button x:Name="BtnUpdateDevicewithlogin" Text="{x:Static local:AppResources.BUpdateDevice}"
Clicked="UpdateDeviceWithLoginButton_Clicked" Grid.Row="7"
BackgroundColor="#f15a23" TextColor="White" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand">
<Button.HeightRequest>
<OnIdiom x:TypeArguments="x:Double" Tablet="55" Phone="45" />
</Button.HeightRequest>
</Button>
</Grid>
<ActivityIndicator x:Name="actIndicator2" Color="#f15a23" Opacity="2"
HeightRequest="50" WidthRequest="50" VerticalOptions="Center" HorizontalOptions="Center"
AbsoluteLayout.LayoutFlags="All" AbsoluteLayout.LayoutBounds="0,0,1,1" />
</AbsoluteLayout>
</custom:KeyboardResizingAwareContentPage.Content>
</custom:KeyboardResizingAwareContentPage>
我使用的是“KeyboardResizingAwareContentPage”页面,而不是“ContentPage”,因为在ios中,当键盘打开时,页面并没有设置。密码字段隐藏在键盘后面,这样用户在键入时就看不到任何内容。这就是我在IOs中使用Render for content Page的原因
如上所示,当我关注用户名或密码输入字段时,键盘后面隐藏着两个按钮。客户端的要求是,在那个时候页面应该是滚动的。我怎样才能解决这个问题?可以通过渲染吗?我在两个平台上都面临着这个问题。(ios和android)即使您不想滚动页面,也可以使用滚动视图作为页面的根目录,并将网格放入其中
这应该可以解决问题。检查:将网格放在ContentPageScrollView中。您得到解决方案了吗?是的,删除AppCompactIt's not working。(我使用网格是因为我的页面设计应该根据设备的高度来设置。页面不会以任何代价滚动,但现在客户端的要求是当键盘打开时页面应该滚动)。我给“*”和自动格式中的每一行指定高度。如果我把我的网格放在滚动视图中,我的网格就会混淆它应该有多高。所以我的设计不合适。