2017-01-31 73 views
0

的最后一排我已经使用xamarin形式的Android AppCompact主题时,键盘弹出其隐藏网格 Before Keyboard Popup see Image键盘弹出其隐藏网格

的最后一行下面是我的代码。我创建了标题,描述的网格。当键盘隐藏时,我想在键盘上方显示相机图标及其栏,并在键盘隐藏时返回屏幕底部。

<Grid RowSpacing="0" VerticalOptions="FillAndExpand"> 
     <Grid.RowDefinitions> 
      <RowDefinition Height="80" /> 
      <RowDefinition Height="*" /> 
      <RowDefinition Height="50" /> 
     </Grid.RowDefinitions> 
     <StackLayout 
      Grid.Row="0" 
      Padding="10,8" 
      BackgroundColor="White" 
      HorizontalOptions="FillAndExpand" 
      Orientation="Horizontal"> 
      <Entry 
       x:Name="GeneralPostTitle" 
       Margin="10,10,10,0" 
       FontSize="20" 
       HorizontalOptions="FillAndExpand" 
       Placeholder="Title" 
       PlaceholderColor="Gray" 
       TextColor="Black" 
       VerticalOptions="End" /> 
     </StackLayout> 
     <StackLayout 
      Grid.Row="1" 
      Padding="10,0" 
      BackgroundColor="White" 
      HorizontalOptions="FillAndExpand" 
      Spacing="0" 
      VerticalOptions="FillAndExpand"> 
      <StackLayout Padding="0" VerticalOptions="Fill"> 
       <customRenderer:PlaceholderEditor 
        x:Name="EditorDescription" 
        Margin="10,10,10,0" 
        FontSize="22" 
        HeightRequest="130" 
        HorizontalOptions="Fill" 
        Placeholder="Add Description" 
        PlaceholderTextColor="Gray" 
        TextColor="Gray" /> 
      </StackLayout> 
      <ScrollView Padding="10" Orientation="Horizontal"> 
       <StackLayout 
        x:Name="Images" 
        HorizontalOptions="FillAndExpand" 
        Orientation="Horizontal" 
        Spacing="5" /> 
      </ScrollView> 
     </StackLayout> 
     <StackLayout 
      Grid.Row="2" 
      Padding="20,0" 
      BackgroundColor="#FAFAFA"> 
      <Image 
       Aspect="AspectFit" 
       HeightRequest="40" 
       HorizontalOptions="StartAndExpand" 
       WidthRequest="30"> 
       <Image.Source> 
        <OnPlatform 
         x:TypeArguments="ImageSource" 
         Android="camera" 
         WinPhone="Icons/camera.png" 
         iOS="Icons/camera.png" /> 
       </Image.Source> 
       <Image.GestureRecognizers> 
        <TapGestureRecognizer Tapped="ImagePost_OnTapped" /> 
       </Image.GestureRecognizers> 
      </Image> 
     </StackLayout> 
    </Grid> 

键盘弹出后看到的图像

enter image description here

+0

你能否发布你的布局代码? –

回答

0

你需要设置SoftInput to AdjustResize,以便为Android来调整意见,使他们保持可见。在Forms中,可以使用Forms 2.3.3中的platform specifics feature来完成此操作。

结账this Gist on how to do this in OnCreate()。请注意,删除添加到API 21+中的状态栏的底层所需的解决方法。

+0

我有使用这个,但是当我们回去没有隐藏键盘比一半屏幕不显示@jimmgarr –

+0

我们如何在Ios中做同样的事情? @jimmgarr –

+0

在iOS上,您将需要使用自定义渲染器,以便您可以响应出现的键盘并调整视图的大小[如此处所示](https://forums.xamarin.com/discussion/comment/95846/#Comment_95846 )。至于你提到的Android问题,我不确定我是否理解。你能创建[一个MCVE](http://stackoverflow.com/help/mcve)吗?谢谢! – jimmgarr