问题
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>
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?
回答1:
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);
来源:https://stackoverflow.com/questions/54309188/scrollview-is-not-working-in-xamarin-forms