I have a typical listview
with an edittext
and a button at the bottom of the activity.
When I click onto the edittext
, the soft keyboard appears, I am able to scroll the items in the listview
but it re-sizes my background image.
I have tried android:windowSoftInputMode="adjustResize"
but no difference.
I have tried android:windowSoftInputMode="adjustPan"
. The image does not get squashed, the whole layout shifts upwards and I lose the title bar. I can only scroll the list if the list items exceed the layout size.
Basically, I want to maintain the title bar, retain the background image without re-sizing and allow scrolling of list items. Anyone managed to do this? Thanks!
for listview you need to use
android:isScrollContainer="false"
and add this to your activity in manifest.xml
android:windowSoftInputMode="adjustPan"
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) ;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With