sagar suri
sagar suri

Reputation: 4731

Building a sectioned HORIZONTAL recyclerview in android

I want to implement the below design in a recyclerview. I am planning to use a sectioned recyclerview. Can someone suggest the approach I should be taking. What is a better approach for this?

Any links for such example or tutorial?

Layout 1: enter image description here

Layout 2:

enter image description here

Layout 3:

enter image description here

Upvotes: 0

Views: 76

Answers (1)

Andrea Ebano
Andrea Ebano

Reputation: 573

you can try something like this:

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.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=".MainActivity">

<TextView
    android:id="@+id/textView"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:hint="TextView"
    android:gravity="left|center"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent" />

<android.support.v7.widget.RecyclerView
    android:id="@+id/recycler_view"
    android:layout_width="match_parent"
    android:layout_height="128dp"
    android:layout_marginTop="8dp"
    android:orientation="horizontal"
    app:layoutManager="android.support.v7.widget.LinearLayoutManager"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toBottomOf="@+id/textView" />

</android.support.constraint.ConstraintLayout>

I think it's ok for the last two examples.

For the first one you can use a custom layout with a recyclerview inside every item of the main recyclerview.

Hope it helps.

Upvotes: 1

Related Questions