How to move the layout up when the soft keyboard i

2019-01-05 10:04发布

I have a login screen with two EditTexts and a login button in my layout. The problem is that, when I start typing, the soft keyboard is shown and covers the login button. How can I push the layout up or above the keyboard when it appears?

I do not want to use a ScrollView, just want to implement it without scrolling down. Please, suggest me some way of doing it. Thanks in advance.

16条回答
姐就是有狂的资本
2楼-- · 2019-01-05 10:38

Accoding to this guide, the correct way to achieve this is by declaring in your manifest:

<activity name="EditContactActivity"
        android:windowSoftInputMode="stateVisible|adjustResize">

    </activity>
查看更多
ら.Afraid
3楼-- · 2019-01-05 10:40

Set windowSoftInputMode property to adjustPan and adjustResize

<activity android:windowSoftInputMode="adjustPan|adjustResize"> </activity>
查看更多
SAY GOODBYE
4楼-- · 2019-01-05 10:41

Try this in the android manifest file corresponding to the activity.

<activity android:windowSoftInputMode="adjustPan"> </activity>
查看更多
你好瞎i
5楼-- · 2019-01-05 10:41

If you are working with xamarin, you can put this code WindowSoftInputMode =Android.Views.SoftInput.AdjustPan | Android.Views.SoftInput.AdjustResize in activity attribute of the MainActivity class. For example, now the activity attribute will look like below

    [Activity(WindowSoftInputMode =Android.Views.SoftInput.AdjustPan | Android.Views.SoftInput.AdjustResize)]
    public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsApplicationActivity
    {
        //some code here.
    }
查看更多
三岁会撩人
6楼-- · 2019-01-05 10:41

This will definitely work for you.

android:windowSoftInputMode="adjustPan"

查看更多
ら.Afraid
7楼-- · 2019-01-05 10:42

I somehow achieved this by knowing the status of the soft keyboard on the device. i move the layout to y position when the keyboard is shown and moved back to its original position when not shown. this works fine, followed this guidelines.

查看更多
登录 后发表回答