Search code examples
androidandroid-recyclerviewscrollviewandroid-nestedscrollview

Recyclerview items invisible/ Missing when keyboard is visible


Problem :

My recyclerview item have one edittext.

If user edit the edittext -> Keyboard will appear & some list items missing. (means recyclerview shrink when keyboard open after keyboard close shrinked recyclerview not expanded)

My xml design

<ScrollView>
<ConstraintLayout>
  <other views>
  <recyclerview/>
</ConstraintLayout>
</ScrollView>

Manifest activity windowSoftInputMode

 android:windowSoftInputMode="adjustPan"

Tried lot of google & SO. But no luck. Anyone give me solution. If anyone need more info let me know. I will give more details.

UPDATE:

My xml code - https://pastebin.com/diz4t9mp

My issue - Video reference

https://drive.google.com/file/d/15J4hOnCM7Gu6uvklhzlSSD7XUCmmGmzg/view?usp=sharing


Solution

  • Change this

    <ScrollView>
    <ConstraintLayout>
      <other views>
      <recyclerview/>
    </ConstraintLayout>
    </ScrollView>
    

    to

    <android.support.v4.widget.NestedScrollView>
    <ConstraintLayout>
      <other views>
      <recyclerview/>
    </ConstraintLayout>
    </android.support.v4.widget.NestedScrollView>
    

    NestedScrollView is used when there is a need for a scrolling view inside another scrolling view. Normally this would be difficult to accomplish since the system would be unable to decide which view to scroll , it supports acting as both a nested scrolling parent and child on both new and old versions of Android.