Page scroll when soft keyboard popped up

前端 未结 10 1073
清歌不尽
清歌不尽 2020-11-30 00:05

I have a layout:




        
相关标签:
10条回答
  • 2020-11-30 00:35

    This only worked for me:

    android:windowSoftInputMode="adjustPan"
    
    0 讨论(0)
  • 2020-11-30 00:40

    Also if you want to do that programmatically just add the below line to the onCreate of the activity.

    getWindow().setSoftInputMode(
                WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE | 
                WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE );
    
    0 讨论(0)
  • 2020-11-30 00:41

    Ok, I have searched several hours now to find the problem, and I found it.

    None of the changes like fillViewport="true" or android:windowSoftInputMode="adjustResize" helped me.

    I use Android 4.4 and this is the big mistake:

    android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen"
    

    Somehow, the Fullscreen themes prevent the ScrollViews from scrolling when the SoftKeyboard is visible.

    At the moment, I ended up using this instead:

    android:theme="@android:style/Theme.Black.NoTitleBar
    

    I don't know how to get rid of the top system bar with time and battery display, but at least I got the problem.

    Hope this helps others who have the same problem.

    EDIT: I got a little workaround for my case, so I posted it here:

    I am not sure if this will work for you, but it will definitely help you in understanding, and clear some things up.

    EDIT2: Here is another good topic that will help you to go in the right direction or even solve your problem.

    0 讨论(0)
  • 2020-11-30 00:45

    put this inside your Manifest like this in No fullscreen Mode

    android:windowSoftInputMode="stateVisible|adjustPan" 
    

    in your manifest

    <activity
        android:windowSoftInputMode="stateVisible|adjustPan"
        android:name="com.example.patronusgps.MainActivity"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
    
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    
    0 讨论(0)
  • 2020-11-30 00:45

    well the simplest answer i tried is just remove your code which makes the activity go full screen .I had a code like this which was responsible for making my activity go fullscreen :

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {

            getWindow().setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS,
                    WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
        }
    

    i just removed my code and it works completely fine although if you want to achieve this with your fullscreen on then you'll have to try some other methods

    0 讨论(0)
  • 2020-11-30 00:51

    In your Manifest define windowSoftInputMode property:

    <activity android:name=".MyActivity"
              android:windowSoftInputMode="adjustNothing">
    
    0 讨论(0)
提交回复
热议问题