Android : Showing keyboard hides listview contents

2019-03-29 05:30发布

问题:

like in this post : Keyboard hides ListView contents

I can't See Contents of my first few rows of my ListView when Keyboard is Visible.

Because my first probleme was to have my element in the bottom so i've follow this tips : Android : Showing keyboard moves my components up, i want to hide them instead

but

android:windowSoftInputMode="adjustPan"

created another issue, my listview is not resize when my keyboard is up and i can't see my first few rows

Thanks

回答1:

I had the same issue and solved this with the below code.

in your activity:

mylistview.setTranscriptMode(ListView.TRANSCRIPT_MODE_NORMAL);
mylistview.setStackFromBottom(true);

or in xml file for

android:stackFromBottom="true"
    android:transcriptMode="normal"

and keeping the adjustResize for activity in manifest file.

<activity .... android:windowSoftInputMode="stateHidden|adjustResize" ..../>

Source: Push Listview when keyboard appears without adjustPan