Kcs computer
Kcs computer

Reputation: 121

View scroll when keyboard open for typing in Entry Control

when user focus Entry Control in Xamarin.Form keyboard open but view scroll so Design looks ugly.so please help me. i have put image how screen visible when keyboard open in android device. My code given below

<StackLayout Grid.Row="1">
        <StackLayout Padding="20,10,20,20" >
            <Entry x:Name="Txtusername" Placeholder="Name"/>
            <Entry x:Name="TxtPass"
                   IsPassword="True"
                   Placeholder="Password" />
            <StackLayout Padding="0,10">
                <Button x:Name="BtnSign"
                        BackgroundColor="#FFFFCB04"
                        BorderColor="#FFFFCB04"
                        Clicked="BtnSignInClicked"
                        Text="Sign In"
                        TextColor="Black" />
            </StackLayout>
        </StackLayout>
    </StackLayout>

Before keyboard open

After keyboard open

Upvotes: 1

Views: 3083

Answers (1)

Akash Amin
Akash Amin

Reputation: 2761

Add WindowSoftInputMode=SoftInput.AdjustPan in your [Activity()] on top of your MainActivity class from where the FormsApplication start.

This is so that your layout does not change when keyboard is active. I think you won't need scroll here. If you want scroll then add scroll view in your code

<ScrollView>
.//your grid 
.
    <StackLayout Grid.Row="1">
        <StackLayout Padding="20,10,20,20" >
            <Entry x:Name="Txtusername" Placeholder="Name"/>
            <Entry x:Name="TxtPass"
                   IsPassword="True"
                   Placeholder="Password" />
            <StackLayout Padding="0,10">
                <Button x:Name="BtnSign"
                        BackgroundColor="#FFFFCB04"
                        BorderColor="#FFFFCB04"
                        Clicked="BtnSignInClicked"
                        Text="Sign In"
                        TextColor="Black" />
            </StackLayout>
        </StackLayout>
    </StackLayout>
</ScrollView>

Upvotes: 0

Related Questions