I have an Android TV app that has a RecyclerView below a TextView. Everything looks great until I click down to the third item which causes the RecyclerView to cover the TextView.
<?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"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:focusable="false"
android:focusableInTouchMode="false"
android:keepScreenOn="true">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clipToPadding="false"
android:clipChildren="false"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent">
<TextView
android:id="@+id/dateTV"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="18sp"
android:layout_marginStart="@dimen/homeHorizontalMargin"
android:paddingBottom="20dp" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recyclerView"
android:layout_below="@id/dateTV"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:layout_marginHorizontal="@dimen/epgRVHorizontalMargin"
android:focusable="false"
android:focusableInTouchMode="false"
android:descendantFocusability="afterDescendants" />
</RelativeLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
How can I stop the RecyclerView from overlapping the TextView?
Your
RecyclerViewparent layout has below propertySo, when you scroll
RecyclerViewit will overlap with other view in layout.You can remove it. Why you use this property here is there any specific reason to design other view in screen?
or you have
ConstraintLayoutas root layout so why you addRelativeLayoutagain and putRecyclerViewinside this layout.You can design your XML layout like below