Android soft keyboard covers edittext field

2018-12-31 13:25发布

Is there a way to make the screen scroll to allow the text field to be seen?

10条回答
长期被迫恋爱
2楼-- · 2018-12-31 14:05

add this single line to your relative activity where key board cover edit text.inside onCreat()method of activity.

getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE | WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
查看更多
有味是清欢
3楼-- · 2018-12-31 14:06
android:windowSoftInputMode="adjustPan"
android:isScrollContainer="true"

works for android EditText, while it not works for webview or xwalkview. When soft keyboard hide the input in webview or xwalkview you have use android:windowSoftInputMode="adjustResize"

查看更多
泛滥B
4楼-- · 2018-12-31 14:10

I had the same issue where the softkeyboard was on top of the EditText views which were placed on the bottom of the screen. I was able to find a solution by adding a single line to my AndroidManifest.xml file's relevant activity.

android:windowSoftInputMode="adjustResize|stateHidden"

This is how the whole activity tag looks like:

<activity
        android:name="com.my.MainActivity"
        android:screenOrientation="portrait"
        android:label="@string/title_activity_main"
        android:windowSoftInputMode="adjustResize|stateHidden" >
    </activity>

Here the most important value is the adjustResize. This will shift the whole UI up to give room for the softkeyboard.

查看更多
旧人旧事旧时光
5楼-- · 2018-12-31 14:15

I had same issues. Try following code:

android:windowSoftInputMode="adjustPan"

add it to your manifest.xml in the activity tag of the activity that holds the input. example:

<activity
            android:name=".Activities.InputsActivity"
            ...
            android:windowSoftInputMode="adjustPan"
            />
查看更多
登录 后发表回答