0

I am trying to implement the Horizontal RecyclerView inside the ViewPager2, but its not working.

<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/black"
    android:paddingLeft="10dp"
    android:paddingRight="10dp">
    <androidx.recyclerview.widget.RecyclerView
        android:id="@+id/rvMusicList"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
        android:orientation="horizontal"
        tools:listitem="@layout/items_music"
        app:layout_constraintTop_toTopOf="parent"
        android:layout_marginTop="30dp"/>
...

My Kotlin Code is below

 rvBottomMenu.apply {
                layoutManager =
                    LinearLayoutManager(this@MainActivity, RecyclerView.HORIZONTAL, false)
                adapter = bottomMenuAdapter
                setHasFixedSize(true)
            }

I tried the below link solution, but not worked: text

3
  • Please provide more information about current solution and what exactly does not work. Commented Jul 26, 2023 at 21:51
  • 1
    I am using inside viewpager, where while scrolling horizontally, it get swipe to another page instead of scrolling. Commented Jul 27, 2023 at 7:43
  • Please add this information to the question. It can be helpful to other people when you find the answer, Commented Jul 27, 2023 at 9:16

1 Answer 1

1

you can try like this! inside view Pager adapter while setting recycler view adapter set LinearLayoutManger as horizontal

 recylcerView.setLayoutManager(new LinearLayoutManager(this, RecyclerView.HORIZONTAL, false));
Sign up to request clarification or add additional context in comments.

1 Comment

I have already used this, even it’s not working. Actually I am using inside viewpager, where while scrolling horizontally, it get swipe to another page instead og scrolling.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.