Scrollview 在 Xamarin Forms 中不起作用 [英] Scrollview is not working in Xamarin Forms

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

问题描述

我的 xamarin 表单应用程序中有以下布局:

I have following layout in my xamarin forms application:

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:telerikInput="clr-namespace:Telerik.XamarinForms.Input;assembly=Telerik.XamarinForms.Input"
             xmlns:telerikPrimitives="clr-namespace:Telerik.XamarinForms.Primitives;assembly=Telerik.XamarinForms.Primitives"
             x:Class="DMGMobile.UserDetailPage">
    <ContentPage.ToolbarItems>
        <ToolbarItem Name="Save" Icon="settings.png" Clicked="Save"></ToolbarItem>
    </ContentPage.ToolbarItems>

    <ContentPage.Content>
        <ScrollView 
            Orientation="Vertical" 
            VerticalScrollBarVisibility="Always"
            VerticalOptions="FillAndExpand">
            <StackLayout
                VerticalOptions="FillAndExpand"
                Padding="10,0,10,0">

                <Label 
                    Text="Name"/>
                <telerikInput:RadEntry 
                    x:Name="User_Name"
                    BackgroundColor="White" 
                    WatermarkText="Name"
                    TextColor="Black"
                    WatermarkTextColor="#C0C0C0">
                    <telerikInput:RadEntry.Padding>
                        <OnPlatform x:TypeArguments="Thickness">
                            <On Platform="Android,UWP" Value="10,10,0,10" />
                            <On Platform="iOS" Value="10,10,0,20" />
                        </OnPlatform>
                    </telerikInput:RadEntry.Padding>
                    <telerikInput:RadEntry.BorderStyle>
                        <telerikInput:BorderStyle 
                            CornerRadius="8"
                            BorderColor="#257cc1"
                            BorderThickness="1" />
                    </telerikInput:RadEntry.BorderStyle>
                </telerikInput:RadEntry>

                <Label 
                    Text="Surname"/>
                <telerikInput:RadEntry 
                    x:Name="User_Vorname"
                    BackgroundColor="White" 
                    WatermarkText="Surname"
                    TextColor="Black"
                    WatermarkTextColor="#C0C0C0">
                    <telerikInput:RadEntry.Padding>
                        <OnPlatform x:TypeArguments="Thickness">
                            <On Platform="Android,UWP" Value="10,10,0,10" />
                            <On Platform="iOS" Value="10,10,0,20" />
                        </OnPlatform>
                    </telerikInput:RadEntry.Padding>
                    <telerikInput:RadEntry.BorderStyle>
                        <telerikInput:BorderStyle 
                        CornerRadius="8"
                        BorderColor="#257cc1"
                        BorderThickness="1" />
                    </telerikInput:RadEntry.BorderStyle>
                </telerikInput:RadEntry>

                <Label 
                    Text="Login"/>
                <telerikInput:RadEntry 
                    x:Name="User_Login"
                    BackgroundColor="White" 
                    WatermarkText="Login"
                    TextColor="Black"
                    WatermarkTextColor="#C0C0C0"
                    TextChanged="User_Login_TextChanged">
                    <telerikInput:RadEntry.Padding>
                        <OnPlatform x:TypeArguments="Thickness">
                            <On Platform="Android,UWP" Value="10,10,0,10" />
                            <On Platform="iOS" Value="10,10,0,20" />
                        </OnPlatform>
                    </telerikInput:RadEntry.Padding>
                    <telerikInput:RadEntry.BorderStyle>
                        <telerikInput:BorderStyle 
                        CornerRadius="8"
                        BorderColor="#257cc1"
                        BorderThickness="1" />
                    </telerikInput:RadEntry.BorderStyle>
                </telerikInput:RadEntry>

                <Label 
                    Text="Pass"/>
                <telerikInput:RadEntry 
                    x:Name="User_Password"
                    BackgroundColor="Transparent" 
                    WatermarkText="Pass"
                    TextColor="Black"
                    WatermarkTextColor="#C0C0C0"
                    TextChanged="User_Login_TextChanged">
                    <telerikInput:RadEntry.Padding>
                        <OnPlatform x:TypeArguments="Thickness">
                            <On Platform="Android,UWP" Value="10,10,0,10" />
                            <On Platform="iOS" Value="10,10,0,20" />
                        </OnPlatform>
                    </telerikInput:RadEntry.Padding>
                    <telerikInput:RadEntry.BorderStyle>
                        <telerikInput:BorderStyle 
                        CornerRadius="8"
                        BorderColor="#257cc1"
                        BorderThickness="1" />
                    </telerikInput:RadEntry.BorderStyle>
                </telerikInput:RadEntry>

                <telerikPrimitives:RadCheckBox 
                    x:Name="User_IsAdmin" />
                <Label 
                    Text="Is admin}"/>

            </StackLayout>
        </ScrollView>
    </ContentPage.Content>
</ContentPage>

问题是 ScrollView 不起作用.尽管 VerticalScrollBarVisibility 设置为 Always,但我什至看不到垂直滚动条.没有键盘的页面看起来不错,但如果显示键盘,则位于页面底部的一些输入被隐藏,我无法滚动以访问它们.

The problem is that ScrollView is not working. I can't even see vertical scrollbar although VerticalScrollBarVisibility is set to Always. The page looks nice without keyboard, but if keyboard shown then some inputs placed on the bottom of the page are hidden and I can't scroll to reach them.

我在这里错过了什么令人讨厌的东西吗?

Am I missing something obious here?

推荐答案

如果你使用的是Android,你可以在MainActivity中的LoadApplication之后添加这个:

If you are using Android, you can add this, after LoadApplication in MainActivity:

Xamarin.Forms.Application.Current.On<Xamarin.Forms.PlatformConfiguration.Android>().UseWindowSoftInputModeAdjust(WindowSoftInputModeAdjust.Resize);

这篇关于Scrollview 在 Xamarin Forms 中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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