Actually I'm trying to use recyclerview
as a viewpager
which is working fine by the help of PagerSnapHelper()
class . But now the problem is how can I force recyclerview
to change item heights dynamically and not show white space . Now when I try to load drawable pictures of two different sizes i.e a small and a bigger at first the smaller one is having correct size but when I scroll to next and then first some white space is shown below the imageView
.You can see aforementioned problems in the given pictures.
XML:
<android.support.v7.widget.RecyclerView
android:id="@+id/rView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
Recyclerview Items:
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/recyclerImgView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
</FrameLayout>
Adapter Code:
@Override
public void onBindViewHolder(ViewHolder holder, int position) {
Glide.with(ctx).load(pics.get(position)).into(holder.imageView);
}
Activity Code:
rView.setLayoutManager(new LinearLayoutManager(getApplicationContext(), LinearLayoutManager.HORIZONTAL,false));
rView.setAdapter(adp);
SnapHelper snapHelper = new PagerSnapHelper();
snapHelper.attachToRecyclerView(rView);