Skip to content

Instantly share code, notes, and snippets.

@danaimset
Created September 13, 2019 10:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danaimset/da40360f0d5fee88c1bcf7fc6aea0268 to your computer and use it in GitHub Desktop.
Save danaimset/da40360f0d5fee88c1bcf7fc6aea0268 to your computer and use it in GitHub Desktop.
<?xml version="1.0" encoding="utf-8"?>
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout 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">
<androidx.core.widget.NestedScrollView
android:id="@+id/nestedScrollView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
android:scrollbarStyle="outsideOverlay"
android:scrollbars="vertical">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.google.android.material.card.MaterialCardView
android:id="@+id/header"
android:layout_width="0dp"
android:layout_height="?android:listPreferredItemHeightLarge"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<!-- ... -->
</com.google.android.material.card.MaterialCardView>
<TextView
android:id="@+id/subtitle1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/marginCompact"
android:layout_marginTop="@dimen/marginLarge"
android:text="Subtitle1"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/header" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/horizontalRecycler"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/subtitle1" />
<TextView
android:id="@+id/subtitle2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Subtitle2"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/horizontalRecycler" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/verticalRecycler"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/subtitle2" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.core.widget.NestedScrollView>
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
@danaimset
Copy link
Author

nestedScrollingEnabled = true for Recyclers

@danaimset
Copy link
Author

In the sample above the first recycler view has horizontal scroll (android:id="@+id/horizontalRecycler")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment