Xamarin Forms:带有键盘的 ScrollView [英] Xamarin Forms: ScrollView with KeyBoard

查看:44
本文介绍了Xamarin Forms:带有键盘的 ScrollView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是最新版本的 Xamarin Forms.我有一个内容页面.内容页面有一个网格,它有一个滚动视图,它有一个堆栈布局,其中包含一些图像和条目输入以及一些按钮.当我触摸 Entry 输入文本时,键盘覆盖了按钮,因此我无法按下按钮.这不可滚动,我不知道为什么.任何人都可以帮助我吗?

这是我的 XAML 代码:

<网格><ScrollView Orientation="Both" x:Name="scrollView"><ScrollView.Content><StackLayout BackgroundColor="#302138"><Image Source="login_logo" Margin="0,0,0,0"></Image><StackLayout BackgroundColor="White" Margin="20,0,20,30"><标签文字="ÜDVÖZÖLJÜK!"FontSize="30" FontFamily="Comic Sans MS" Margin="0,15,0,0" TextColor="#302138" Horizo​​ntalTextAlignment="Center"></Label><Entry Text="{Binding Email}" Placeholder="E-mail" Margin="40,0,40,0" Keyboard="Email"/><Entry Text="{绑定密码}" Placeholder="Jelszó" IsPassword="True" Margin="40,0,40,0"/><Button Text="BEJELENTKEZÉS" Clicked="Login" TextColor="White" BackgroundColor="#302138" Margin="40,10,40,0"/><Button Text="REGISZTRÁCIÓ" Clicked="Register" TextColor="White" BackgroundColor="#302138" Margin="40,0,40,25"/></StackLayout></StackLayout></ScrollView.Content></ScrollView></网格>

I am on the most current version of Xamarin Forms. I have a Content Page. The Content Page has a grid that has a scrollview that has a stacklayout that contains some image and Entry inputs and some Buttons. When I touch the Entry to enter text, the keyboard covers the Buttons so I can't press the button. This isn't scrollable and I don't know why. Anybody can help me?

Here is my XAML code:

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
         xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
         x:Class="Spirocco.LoginPage">
<Grid>
    <ScrollView Orientation="Both" x:Name="scrollView">
        <ScrollView.Content>
            <StackLayout BackgroundColor="#302138">
                <Image Source="login_logo" Margin="0,0,0,0"></Image>
                <StackLayout BackgroundColor="White" Margin="20,0,20,30">
                    <Label Text="ÜDVÖZÖLJÜK!" FontSize="30" FontFamily="Comic Sans MS" Margin="0,15,0,0" TextColor="#302138" HorizontalTextAlignment="Center"></Label>
                    <Entry Text="{Binding Email}" Placeholder="E-mail" Margin="40,0,40,0" Keyboard="Email"/>
                    <Entry Text="{Binding Password}" Placeholder="Jelszó" IsPassword="True" Margin="40,0,40,0"/>
                    <Button Text="BEJELENTKEZÉS" Clicked="Login" TextColor="White" BackgroundColor="#302138" Margin="40,10,40,0"/>
                    <Button Text="REGISZTRÁCIÓ" Clicked="Register" TextColor="White" BackgroundColor="#302138" Margin="40,0,40,25"/>
                </StackLayout>
            </StackLayout>
        </ScrollView.Content>
    </ScrollView>
</Grid>

Here is the solution

解决方案

Just add this code to App.xaml.cs to make page auto-resizable

using Xamarin.Forms.PlatformConfiguration.AndroidSpecific;

public partial class App : Xamarin.Forms.Application
{
    public App ()
    {
        Xamarin.Forms.Application.Current.On<Xamarin.Forms.PlatformConfiguration.Android>().UseWindowSoftInputModeAdjust(WindowSoftInputModeAdjust.Resize);
        InitializeComponent();

        MainPage = new NavigationPage(new LoginTabsPage()){
        ...

这篇关于Xamarin Forms:带有键盘的 ScrollView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆