I am setting images and video from local phone storage to recyclerview with Staggered LayoutManager with kotlin. Every thing is fine but on first launch recyclerview shows all images and video in only one column(on right side only) , Everything is normal on refershing on recyclerview. I have set span count 2 and using glide. I am new with this, thanks in advance.
Here is some code.
recyclerview?.setHasFixedSize(true)
recyclerview.layoutManager = StaggeredGridLayoutManager(2,StaggeredGridLayoutManager.VERTICAL)
adapter = ImageAdapter(activity)
recyclerview?.adapter = adapter
adapter?.notifyDataSetChanged()
Layout for recyclerview:
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/img"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:scaleType="fitCenter" />
</RelativeLayout>