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
Desired result
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.
try
android:windowSoftInputMode="adjustPan|stateVisible"
You could automatically scroll to the bottom of your activity by yourself, by overriding the onConfigurationChanged() callback in you Activity
:
scrollView.post(new Runnable() {
@Override
public void run() {
scrollView.fullScroll(View.FOCUS_DOWN);
}
});
This means you also have to tell your activity you want the callback to be called when the activity changes its layout by using the configChanges attribute in the activity declaration in your AndroidManifest file :
<activity
android:configChanges="screenLayout|screenSize" <!-- Don't know which could actually do the trick -->
... >
</activity>
I hope this can help you.
In Manifest:
android:windowSoftInputMode="adjustPan|stateVisible"
In layout xml bottom of all child layout of scrollview set one textview, such as
<ScrollView
android:id="@+id/driverLoginScrollView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fillViewport="false"
android:scrollbars="none">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginTop="50dp"
android:focusable="true"
android:focusableInTouchMode="true"
android:orientation="vertical">
.
.
.
<TextView
android:layout_width="match_parent"
android:layout_height="100dp"
android:focusable="false"
android:textIsSelectable="false" />
</LinearLayout>
</ScrollView>
I found that if I had set layout parameters on my scroll view, then it would not work. As soon as a removed the layout parameters it worked as expected. I can't explain why, just letting others know what worked for me.