Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why doesn't android:windowSoftInputMode="stateVisible|adjustResize" adjust the screen when soft keyboard is shown?

I can't seem to make the android:windowSoftInputMode="stateVisible|adjustResize" option work. When the soft keyboard shows, the scroll view doesn't automatically scroll to the bottom part.

Edit: I tried using adjustPan instead (stateVisible|adjustPan) but what happens is the scroll view gets disabled.

Solution: Finally, I found a suggestion that works. I created an OnGlobalLayoutListener() and added it to my scroll view. I checked if the height of the root view of my activity(which is my scroll view) changed. If yes, I'm assuming that the soft keyboard is shown.

Click here for more info.

Here's my source code:

AndroidManifest.xml

<application
        ...
        android:theme="@android:style/Theme.NoTitleBar" >
        <activity
            ...
            android:screenOrientation="portrait"
            android:windowSoftInputMode="stateVisible|adjustResize" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        ...
</application>

Login Screen with keyboard - scroll view does not scroll enter image description here

Desired result enter image description here

like image 903
Jerome Christopher Geronimo Avatar asked Nov 02 '22 04:11

Jerome Christopher Geronimo


1 Answers

Solution: Finally, I found a suggestion that works. I created an OnGlobalLayoutListener() and added it to my scroll view. I checked if the height of the root view of my activity(which is my scroll view) changed. If yes, I'm assuming that the soft keyboard is shown.

Click here for more info.

like image 71
Jerome Christopher Geronimo Avatar answered Nov 16 '22 08:11

Jerome Christopher Geronimo