Adjust scrollview when keyboard is up

前端 未结 6 1103
抹茶落季
抹茶落季 2021-01-08 00:43

I have an activity with a form in it. Because the form is quite long, I\'ve used a scrollview.

The problem is that the scrollview doesn\'t change when the keyboard i

相关标签:
6条回答
  • 2021-01-08 00:56

    if you use fragment, you just need to use the code to control it, like below

    context.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);

    0 讨论(0)
  • 2021-01-08 00:57

    In the application's manifest file, add the following to the desired <activity /> --

     android:windowSoftInputMode="stateAlwaysHidden|adjustResize|adjustPan"
    
    0 讨论(0)
  • 2021-01-08 00:58

    You need to add android:windowSoftInputMode="adjustResize" in the AndroidManifest.xml file.

    0 讨论(0)
  • 2021-01-08 01:05

    Note, if you are using CoordinatorLayout, make sure you set android:fitsSystemWindows="false" to be able to make it work for "adjustResize"

    The above answers are not enough!

    See this article

    https://code.luasoftware.com/tutorials/android/move-layout-when-keyboard-shown/

    0 讨论(0)
  • 2021-01-08 01:10

    For ScrollView, I like to use the following soft input mode for the Activity in the AndroidManifest.xml file:

    android:windowSoftInputMode="adjustPan"
    

    This works the best for me out of the other options.

    0 讨论(0)
  • 2021-01-08 01:21
    1. <ScrollView ... android:layout_height="fill_parent" android:fillViewport="true" android:fitsSystemWindows="true" />
    2. Manifest <activity ... android:windowSoftInputMode="stateHidden|adjustResize" /> it's work for me
    0 讨论(0)
提交回复
热议问题