KeyboardAvoidingView not Working Properly

前端 未结 14 2396
悲&欢浪女
悲&欢浪女 2020-12-02 08:51

KeyboardAvoidingView not Working Properly

I am trying to use the KeyboardAvoidingView with behavior="padding".

For some reason, when I

14条回答
  •  甜味超标
    2020-12-02 09:41

    WARNING

    This appears to be only a partial solution, although it works initially, if the android phone is locked on the screen with the keyboard avoiding layout, when you unlock you end up with the extra padding above the keyboard again.

    tl;dr

    Remove android:windowSoftInputMode="adjustResize" from the AndroidManifest.xml

    Before

    ...
    
    ...
    

    After

    ...
    
    ...
    

    Why

    If I understand the issue correctly, I have been dealing with the same thing. By having android:windowSoftInputMode="adjustResize" in the manifest, the android system will try to do the same job as the KeyboardAvoidingView. This results in extra spacing being added above the keyboard on Android only.

    If working on both platforms you are going to have to deal with this on iOS every time you are working with keyboard input, so best to remove the android specific behaviour by android:windowSoftInputMode="adjustResize" from the manifest and using the KeyboardAvoidingView every time.

提交回复
热议问题