键盘弹出其隐藏最后一行网格

时间:2017-01-31 05:10:52

标签: xaml xamarin xamarin.android xamarin.forms

我在xamarin表单中使用了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

1 个答案:

答案 0 :(得分:0)

您需要设置SoftInput to AdjustResize以便Android调整视图大小以使其保持可见状态。在表单中,您可以使用表单2.3.3中的platform specifics feature执行此操作。

结帐this Gist on how to do this in OnCreate()。请注意删除添加到API 21 +中状态栏的参考底图所需的变通方法。