Xamarin 与输入字段重叠的键盘

Xamarin 与输入字段重叠的键盘,xamarin,xamarin.forms,keyboard,Xamarin,Xamarin.forms,Keyboard,我有一个视图,其中包含保存在scrollView中的输入字段,在这里,当我点击输入字段时,键盘弹出窗口并覆盖其余字段,我无法解决我的问题。我将我的主要活动更改为[活动(Label=“MyApp”,Icon=“@drawable/Icon”,Theme=“@style/MainTheme”,MainLauncher=false,ConfigurationChanges=ConfigChanges.ScreenSize | ConfigChanges.Orientation,WindowsOfInp

我有一个视图,其中包含保存在scrollView中的输入字段,在这里,当我点击输入字段时,键盘弹出窗口并覆盖其余字段,我无法解决我的问题。我将我的主要活动更改为
[活动(Label=“MyApp”,Icon=“@drawable/Icon”,Theme=“@style/MainTheme”,MainLauncher=false,ConfigurationChanges=ConfigChanges.ScreenSize | ConfigChanges.Orientation,WindowsOfInputMode=SoftInput.AdjustResize)]
并检查是否有
AdjustPan
无效,当键盘弹出时如何将这些字段滚动到最后一个字段

<ContentView>
<Grid>
  <Grid.RowDefinitions>
    <RowDefinition Height="*"/>
    <RowDefinition Height="Auto"/>
  </Grid.RowDefinitions>
  <ScrollView Orientation="Vertical">
  <StackLayout Grid.Row="0" HorizontalOptions="FillAndExpand" VerticalOptions="CenterAndExpand" Padding="10">
    <StackLayout.Spacing>
      <OnIdiom x:TypeArguments ="x:Double" Phone = "8" Tablet ="16"/>
    </StackLayout.Spacing>
    <Entry x:Name="FirstNameEntry" PlaceholderColor="#9E9E9E" Text="{Binding FirstName}" Placeholder="First name" HorizontalOptions="FillAndExpand" TextColor="#191919" FontFamily="Avenir Book">
      <Entry.HeightRequest>
        <OnIdiom x:TypeArguments="x:Double">
          <OnIdiom.Phone>
            <OnPlatform x:TypeArguments="x:Double" iOS="30" Android="40" WinPhone="28" />
          </OnIdiom.Phone>
          <OnIdiom.Tablet>
            <OnPlatform x:TypeArguments="x:Double" iOS="40" Android="45" WinPhone="28" />
          </OnIdiom.Tablet>
        </OnIdiom>
      </Entry.HeightRequest>         
    </Entry>
    <Entry x:Name="LastNameEntry" Text="{Binding LastName}" PlaceholderColor = "#9E9E9E" Placeholder="Last name" HorizontalOptions="FillAndExpand" TextColor="#191919" FontFamily="Avenir Book">
      <Entry.HeightRequest>
        <OnIdiom x:TypeArguments="x:Double">
          <OnIdiom.Phone>
            <OnPlatform x:TypeArguments="x:Double" iOS="30" Android="40" WinPhone="28" />
          </OnIdiom.Phone>
          <OnIdiom.Tablet>
            <OnPlatform x:TypeArguments="x:Double" iOS="40" Android="45" WinPhone="28" />
          </OnIdiom.Tablet>
        </OnIdiom>
      </Entry.HeightRequest>         
    </Entry>
    <Entry x:Name="MobileNameEntry" Keyboard="Numeric" PlaceholderColor="#9E9E9E" Text="{Binding MobileNumber}" TextChanged = "On_PhoneNumberTextChanged" Placeholder="Mobile number" HorizontalOptions="FillAndExpand" TextColor="#191919" FontFamily="Avenir Book">
      <Entry.HeightRequest>
        <OnIdiom x:TypeArguments="x:Double">
          <OnIdiom.Phone>
            <OnPlatform x:TypeArguments="x:Double" iOS="30" Android="40" WinPhone="28" />
          </OnIdiom.Phone>
          <OnIdiom.Tablet>
            <OnPlatform x:TypeArguments="x:Double" iOS="40" Android="45" WinPhone="28" />
          </OnIdiom.Tablet>
        </OnIdiom>
      </Entry.HeightRequest>         
    </Entry>
    <Entry x:Name="HouseNumberEntry" Text="{Binding HouseNumber}" PlaceholderColor="#9E9E9E" Placeholder="House number" HorizontalOptions="FillAndExpand" TextColor="#191919" FontFamily="Avenir Book">
      <Entry.HeightRequest>
        <OnIdiom x:TypeArguments="x:Double">
          <OnIdiom.Phone>
            <OnPlatform x:TypeArguments="x:Double" iOS="30" Android="40" WinPhone="28" />
          </OnIdiom.Phone>
          <OnIdiom.Tablet>
            <OnPlatform x:TypeArguments="x:Double" iOS="40" Android="45" WinPhone="28" />
          </OnIdiom.Tablet>
        </OnIdiom>
      </Entry.HeightRequest>
    </Entry>
    <Entry x:Name="StreetNameEntry" Text="{Binding StreetName}" PlaceholderColor="#9E9E9E" Placeholder="Street name" HorizontalOptions="FillAndExpand" TextColor="#191919" FontFamily="Avenir Book">
      <Entry.HeightRequest>
        <OnIdiom x:TypeArguments="x:Double">
          <OnIdiom.Phone>
            <OnPlatform x:TypeArguments="x:Double" iOS="30" Android="40" WinPhone="28" />
          </OnIdiom.Phone>
          <OnIdiom.Tablet>
            <OnPlatform x:TypeArguments="x:Double" iOS="40" Android="45" WinPhone="28" />
          </OnIdiom.Tablet>
        </OnIdiom>
      </Entry.HeightRequest>
    </Entry>
    <Entry x:Name="CityNameEntry" Text="{Binding City}" PlaceholderColor="#9E9E9E" Placeholder="City" HorizontalOptions="FillAndExpand" TextColor="#191919" FontFamily="Avenir Book">
      <Entry.HeightRequest>
        <OnIdiom x:TypeArguments="x:Double">
          <OnIdiom.Phone>
            <OnPlatform x:TypeArguments="x:Double" iOS="30" Android="40" WinPhone="28" />
          </OnIdiom.Phone>
          <OnIdiom.Tablet>
            <OnPlatform x:TypeArguments="x:Double" iOS="40" Android="45" WinPhone="28" />
          </OnIdiom.Tablet>
        </OnIdiom>
      </Entry.HeightRequest>
    </Entry>
    <Entry x:Name="PostCodeEntry" Text="{Binding PostalCode}" PlaceholderColor="#9E9E9E" Placeholder="Post code" HorizontalOptions="FillAndExpand" TextColor="#191919" FontFamily="Avenir Book">
      <Entry.HeightRequest>
        <OnIdiom x:TypeArguments="x:Double">
          <OnIdiom.Phone>
            <OnPlatform x:TypeArguments="x:Double" iOS="30" Android="40" WinPhone="28" />
          </OnIdiom.Phone>
          <OnIdiom.Tablet>
            <OnPlatform x:TypeArguments="x:Double" iOS="40" Android="45" WinPhone="28" />
          </OnIdiom.Tablet>
        </OnIdiom>
      </Entry.HeightRequest>
    </Entry>
    <Picker x:Name="AddressTypePicker" Title="Select type" HorizontalOptions="FillAndExpand" SelectedIndexChanged="AddressTypePicker_OnSelectedIndexChanged">
      <Picker.HeightRequest>
        <OnIdiom x:TypeArguments="x:Double">
          <OnIdiom.Phone>
            <OnPlatform x:TypeArguments="x:Double" iOS="30" Android="40" WinPhone="28" />
          </OnIdiom.Phone>
          <OnIdiom.Tablet>
            <OnPlatform x:TypeArguments="x:Double" iOS="40" Android="45" WinPhone="28" />
          </OnIdiom.Tablet>
        </OnIdiom>
      </Picker.HeightRequest>
    </Picker>
  </StackLayout>
    </ScrollView>
  <StackLayout BackgroundColor="#f2c646" Grid.Row="1" Orientation="Horizontal" HorizontalOptions="FillAndExpand" VerticalOptions="End" Padding="0">
    <StackLayout.HeightRequest>          
      <OnIdiom x:TypeArguments="x:Double">
          <OnIdiom.Phone>
            <OnPlatform x:TypeArguments="x:Double" iOS="40" Android="50" WinPhone="28" />
          </OnIdiom.Phone>
          <OnIdiom.Tablet>
            <OnPlatform x:TypeArguments="x:Double" iOS="50" Android="60" WinPhone="28" />
          </OnIdiom.Tablet>
        </OnIdiom>
    </StackLayout.HeightRequest>
    <StackLayout Padding="10">
      <Label Text="Cancel" TextColor="Black" HorizontalOptions="StartAndExpand" FontFamily="Avenir Book" VerticalTextAlignment="Center">
        <Label.GestureRecognizers>
          <TapGestureRecognizer Tapped="OnCancelBtnClicked"/>
        </Label.GestureRecognizers>
        <Label.FontSize>              
          <OnIdiom x:TypeArguments="x:Double">
          <OnIdiom.Phone>
            <OnPlatform x:TypeArguments="x:Double" iOS="15" Android="17" WinPhone="28" />
          </OnIdiom.Phone>
          <OnIdiom.Tablet>
            <OnPlatform x:TypeArguments="x:Double" iOS="20" Android="22" WinPhone="28" />
          </OnIdiom.Tablet>
        </OnIdiom>
        </Label.FontSize>
      </Label>
    </StackLayout>
    <StackLayout HorizontalOptions="EndAndExpand" Padding="10">
      <Label Text="Save" TextColor="Black" VerticalTextAlignment="Center" FontFamily="Avenir Book">
        <Label.GestureRecognizers>
          <TapGestureRecognizer Command="{Binding SaveCommand}"/>
        </Label.GestureRecognizers>
        <Label.FontSize>
          <OnIdiom x:TypeArguments="x:Double">
          <OnIdiom.Phone>
            <OnPlatform x:TypeArguments="x:Double" iOS="15" Android="17" WinPhone="28" />
          </OnIdiom.Phone>
          <OnIdiom.Tablet>
            <OnPlatform x:TypeArguments="x:Double" iOS="20" Android="22" WinPhone="28" />
          </OnIdiom.Tablet>
        </OnIdiom>
        </Label.FontSize>
      </Label>
    </StackLayout>
  </StackLayout>
</Grid>


我相信您有一个注册表格的情况。为什么不将tableview与
Intent=“Form”
一起使用呢?因为tableview有一个内置的滚动条,可以适应在视图中保留条目的行为。它还提供了一种形式的本地外观

我在我的一个项目中使用了它,它在iOS和Android上都运行得非常好

<TableView Intent="Form" HasUnevenRows="true">
</TableView>

参考:

希望这有帮助