2017-10-06 75 views
0

我有一个视图,其中包含保存在scrollView中的输入字段,在这里,当我点击输入字段的键盘弹出并覆盖剩余的字段,通过以下this我无法解决我的问题.i chnged我的主要活动为[Activity(Label = "MyApp", Icon = "@drawable/icon", Theme = "@style/MainTheme", MainLauncher = false, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation, WindowSoftInputMode = SoftInput.AdjustResize)]并且还检查了AdjustPan没有任何工作,如何在keyboardpopups时将这些字段滚动到最后一个字段?键盘重叠的输入字段

<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> 

回答

1

我相信你有注册表格的局面。为什么不使用Intent="Form"的tableview,因为表格视图有一个内置的滚动条,可以适应keep-in-view-behavior行为。它也提供了本机的外观。

我在我的一个项目中使用它,它在iOS和Android上都完美运行。

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

参考:TableView

希望这有助于

+0

Tq的,但我得到了我的http://xamarinformscorner.blogspot.in/解决 – sahithi