How to prevent Soft Keyboard from resizing background image

前端 未结 12 1833
耶瑟儿~
耶瑟儿~ 2020-12-30 00:09

I have a typical listview with an edittext and a button at the bottom of the activity.

When I click onto the edittext, the sof

12条回答
  •  清酒与你
    2020-12-30 00:50

    I have tried so may solutions for solving this problem. android:windowSoftInputMode="adjustPan" will make your whole screen shift with keyboard. Generally we have a title of the screen on the top. Using this flag it will also go out of the visible area, which make bad user experience. I use android:windowSoftInputMode="adjustResize" This will resize the whole screen but it will cause the same problem @Maurice state in the question.

    So here is my final solution:

    In Manifest

    android:windowSoftInputMode="adjustResize|stateAlwaysHidden"
    

    In XMl

    Dont Set any background here.And keep your view under ScrollView

    In Java

    You need to set the background to window:

    getWindow().setBackgroundDrawableResource(R.drawable.bg_wood) ;
    

提交回复
热议问题