A.Goutam
A.Goutam

Reputation: 3494

entry text Disappear by keyboard

I am creating a mobile app using Xamarin form using PCL. A text box always hides from the keyboard in iOS, but this part is working perfectly in Android. Below is my Xaml

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             x:Class="MYDriver.List"             
             WidthRequest="20" BackgroundColor="#ffffff" >   
    <ContentPage.Content >        
            <StackLayout x:Name="InBoundlayout">             
             <StackLayout x:Name="ToolBar" Style="{StaticResource ToolbarOuter}" Padding="0,20,0,0">
                <StackLayout Style="{StaticResource ToolbarInner1}">

                    <Image Source="back3.png" >
                        <Image.GestureRecognizers>
                            <TapGestureRecognizer
                      Tapped="Back_Clicked"  />
                        </Image.GestureRecognizers>
                    </Image>
                </StackLayout>

                <StackLayout Style="{StaticResource ToolbarInner1} " >
                    <Image Source="home3.png">
                        <Image.GestureRecognizers>
                            <TapGestureRecognizer
                      Tapped="Home_Clicked"  />
                        </Image.GestureRecognizers>
                    </Image>
                </StackLayout>
                <StackLayout Style="{StaticResource ToolbarInner1}" >
                    <Image x:Name="PicTorchLight" >
                        <Image.GestureRecognizers>
                            <TapGestureRecognizer Tapped="TorchLight_Clicked"  />
                        </Image.GestureRecognizers>
                    </Image>
                </StackLayout>
                <StackLayout Style="{StaticResource ToolbarInner2}">
                    <Label x:Name="lblUserName" Style="{StaticResource ToolbarLabel}" />
                    <Image Source="logout.png">
                        <Image.GestureRecognizers>
                            <TapGestureRecognizer
                      Tapped="Logout_Clicked"  />
                        </Image.GestureRecognizers>
                    </Image>
                </StackLayout>
            </StackLayout>           
             <StackLayout x:Name="layoutHead" Style="{StaticResource HeadColour}" Margin="0,-5">

                <StackLayout Spacing="0" Orientation="Horizontal" HorizontalOptions="Start">
                    <Label Text="  #" Style="{StaticResource HeadForAllorderDetails}" />
                </StackLayout>

                <StackLayout Spacing="0" Orientation="Horizontal" HorizontalOptions="EndAndExpand">
                    <Label Text="Order No" Style="{StaticResource HeadForAllorderDetails}" />
                </StackLayout>

                <StackLayout Spacing="0" Orientation="Horizontal" HorizontalOptions="StartAndExpand">
                    <Label Text="         Ref" Style="{StaticResource HeadForAllorderDetails}" />
                </StackLayout>

                <StackLayout Spacing="0" Orientation="Horizontal" HorizontalOptions="EndAndExpand">
                    <Label Text="Dropoff" Style="{StaticResource HeadForAllorderDetails}" />
                </StackLayout>

                <StackLayout Spacing="0" Orientation="Horizontal" HorizontalOptions="EndAndExpand">
                    <Label Text="          Items" Style="{StaticResource HeadForAllorderDetails}" />
                </StackLayout>

                <StackLayout Spacing="0" Orientation="Horizontal" HorizontalOptions="EndAndExpand">
                    <Label Text="Status" Style="{StaticResource HeadForAllorderDetails}" />
                </StackLayout>
            </StackLayout>

             <StackLayout x:Name="listViewOredr1">
                        <ListView x:Name="listViewOredr" ItemTapped="OnActivitySelected" HasUnevenRows="True"  >
                            <ListView.ItemTemplate>
                                <DataTemplate>
                                    <ViewCell>
                                        <Frame   HasShadow="True" OutlineColor="Silver"   Padding="3">
                                            <Grid BackgroundColor="{Binding RowColour}" ColumnSpacing="2" Padding="2" >

                                              <StackLayout x:Name="rr"  Orientation="Horizontal" HeightRequest="35" BackgroundColor="{Binding RowColour}" Padding="10">

                                                    <StackLayout Spacing="0" BackgroundColor="{Binding RowColour}" Orientation="Horizontal" HorizontalOptions="Start">
                                                        <Label FontSize="10" TextColor="#707070" Text="{Binding DROPROUTEPOS_}" HorizontalOptions="StartAndExpand" VerticalOptions="Center"/>
                                                    </StackLayout>

                                                    <StackLayout Spacing="0" BackgroundColor="{Binding RowColour}" Orientation="Horizontal" HorizontalOptions="EndAndExpand">
                                                        <Label FontSize="10" TextColor="#707070" Text="{Binding ORDERNUM}" HorizontalOptions="StartAndExpand" VerticalOptions="Center"/>
                                                    </StackLayout>

                                                    <StackLayout Spacing="0" BackgroundColor="{Binding RowColour}" Orientation="Horizontal" HorizontalOptions="EndAndExpand">
                                                        <Label FontSize="10" TextColor="#707070" Text="{Binding REF}" HorizontalOptions="StartAndExpand" VerticalOptions="Center" />
                                                    </StackLayout>

                                                    <StackLayout Spacing="0" BackgroundColor="{Binding RowColour}" Orientation="Horizontal" HorizontalOptions="EndAndExpand">
                                                        <Label FontSize="10" TextColor="#707070" Text="{Binding DROPOFF}" HorizontalOptions="StartAndExpand" VerticalOptions="Center" />
                                                    </StackLayout>

                                                    <StackLayout Spacing="0" BackgroundColor="{Binding RowColour}" Orientation="Horizontal" HorizontalOptions="EndAndExpand">
                                                        <Label FontSize="10" TextColor="#707070" Text="{Binding ItemScanStatus}" HorizontalOptions="StartAndExpand" VerticalOptions="Center" />
                                                    </StackLayout>

                                                    <StackLayout Spacing="0" BackgroundColor="{Binding RowColour}" Orientation="Horizontal" HorizontalOptions="EndAndExpand">
                                                        <Image Aspect="AspectFit" HorizontalOptions="StartAndExpand" VerticalOptions="Center" HeightRequest = "20" WidthRequest="20" Source = "{Binding ImageStatus}"  />
                                                    </StackLayout>
                                                </StackLayout>

                                           </Grid>
                                        </Frame>
                                    </ViewCell>
                                </DataTemplate>
                            </ListView.ItemTemplate>
                        </ListView>
                    </StackLayout>

             <StackLayout x:Name="layoutouterFrame" BackgroundColor="Green" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand">
                <Frame Padding = "5" BackgroundColor="#ffffff">
                    <StackLayout Orientation="Horizontal">
                        <Grid x:Name="grid">                           
                        </Grid>                        
                    </StackLayout>
                </Frame>
            </StackLayout>

             <StackLayout x:Name="layoutForBluetooth" HeightRequest = "200"  BackgroundColor="#5DCBEE" Orientation="Horizontal" HorizontalOptions="FillAndExpand">
                       <Frame HorizontalOptions="FillAndExpand" OutlineColor="Black" HasShadow="True">-->
                        <Grid>
                            <Label Text="Scan Your Barcode" x:Name="lblDriverNumber" TextColor="Black" FontSize="Medium" HorizontalOptions="FillAndExpand" Margin="0,10" />
                            <Entry x:Name="txtentry" FontSize="Medium" TextColor="Black" WidthRequest="400" HorizontalOptions="FillAndExpand" VerticalOptions="CenterAndExpand" Margin="0,10" />
                        </Grid>
                        </Frame> 
                    </StackLayout>

            </StackLayout>         
    </ContentPage.Content>
</ContentPage> 

Can you please tell me how to stop the keyboard to hide the text box that is <Entry x:Name="txtentry" in above XAML.

Upvotes: 2

Views: 653

Answers (1)

Michał Żołnieruk
Michał Żołnieruk

Reputation: 2105

It's quite a typical problem on iOS and there's a ready nuget plugin which you just need to import to your app and initialize. It will check whether the keyboard is not hiding the edited textbox and move the whole page up if it's needed.

https://www.nuget.org/packages/Xam.Plugins.Forms.KeyboardOverlap/

Upvotes: 1

Related Questions