1

this is my adapter

I want to scroll one item each time i scroll. Like when you see multiple images post on instagram. How can i do that?

Thanks

recyclerViewyeterr=findViewById(R.id.recyclerViewyeterr);

LinearLayoutManager horizontalLayoutManagaer = new LinearLayoutManager(GYUserSahaDetay.this, 
LinearLayoutManager.HORIZONTAL, false);

recyclerViewyeterr.setLayoutManager(horizontalLayoutManagaer);

gYresimadaptor=new GYresimadaptor(resimler2);

recyclerViewyeterr.setAdapter(gYresimadaptor);

and my XML;

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".GYresimadaptor">

<ImageView
android:id="@+id/imageView33"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:srcCompat="@tools:sample/avatars" />

</androidx.constraintlayout.widget.ConstraintLayout>
The Codepreneur
  • 236
  • 3
  • 12
  • Does this answer your question? [use RecyclerView like vertical viewpager](https://stackoverflow.com/questions/37996026/use-recyclerview-like-vertical-viewpager) – ADM Mar 21 '21 at 04:36

2 Answers2

1

You can use a SnapHelper by attaching it to your RecyclerView with SnapHalper.attachToRecyclerView() and you will have a Scroll effect like instagram for example :

recyclerViewyeterr=findViewById(R.id.recyclerViewyeterr);

LinearLayoutManager horizontalLayoutManagaer = new LinearLayoutManager(GYUserSahaDetay.this, 
LinearLayoutManager.HORIZONTAL, false);

recyclerViewyeterr.setLayoutManager(horizontalLayoutManagaer);

gYresimadaptor=new GYresimadaptor(resimler2);

recyclerViewyeterr.setAdapter(gYresimadaptor);

SnapHelper snapHelper = new PagerSnapHelper();
snapHelper.attachToRecyclerView(recyclerViewyeterr);
Shay Kin
  • 2,539
  • 3
  • 15
  • 22
  • Hi @BatuhanAtak i, I see you're new to SO. If you feel an answer solved the problem, please mark it as 'accepted' by clicking the green check mark and use vote up . This helps keep the focus on older SO which still don't have answers. – Shay Kin Mar 20 '21 at 15:46
  • 1
    @BatuhanAtak [Check it](https://i.stack.imgur.com/KZWEr.png)... how to mark as a correct answer... –  Mar 20 '21 at 16:24
1

As much as understand, you want to make this For rv like instagram more than 1 photo post or history you have to use this layout manager code and you have to design card view full width.

this is general solve

rv.setLayoutManager(new StaggeredGridLayoutManager(1,StaggeredGridLayoutManager.HORIZONTAL));
Emre Ozcan
  • 43
  • 7