I have implemented a RecyclerView
with SearchView
and Filterable
; all classes from v7
. Now there is this behavior that is annoying. Whenever the keyboard is brought up or closed the contents of the RecyclerView
goes blank. The count is still correct but the view is empty. My guess, it has something to do with the Layout
size change. Is this behavior normal or something is wrong? How to deal with it? I can show the code but don't quite know which part will be relevant so tell me what can I add here?
While typing in the question, found this from the similar questions.
Please add following line to your activity in manifest. Hope it works. android:windowSoftInputMode="adjustPan"
More precisely, add android:windowSoftInputMode="adjustPan"
in the activity
tag in AndroidMenifest.xml
where the keyboard is going to be opened.
Example:
<activity
android:name=".FManagerActivity"
android:label="@string/app_name"
android:windowSoftInputMode="adjustPan"
android:theme="@style/AppTheme.Light.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
It is basically the behavior in which the activity reacts when the keyboard is opened or closed. adjustPan
tells the keyboard to overlay the view of the activity not disturbing it's content. Without that when the keyboard is opened the size of the activity also changes which makes the content disappear as notifyDatasetChanged()
is not called during and after the implicit actions.