2017-01-31 69 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