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

后端 未结 5 1815
情书的邮戳
情书的邮戳 2021-01-03 03:02

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

相关标签:
5条回答
  • 2021-01-03 03:40

    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.

    0 讨论(0)
  • 2021-01-03 03:49

    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.

    0 讨论(0)
  • 2021-01-03 03:55

    try

    android:windowSoftInputMode="adjustPan|stateVisible"
    
    0 讨论(0)
  • 2021-01-03 03:56

    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.

    0 讨论(0)
  • 2021-01-03 03:59

    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>
    
    0 讨论(0)
提交回复
热议问题