如何配置 XML 文件以使 RecyclerView 不与其余内容重叠?

How to configure XML file so RecyclerView doesn't overlap the rest of the content?

我的布局文件当前做什么:

构建应用程序后我的布局文件看起来像 picture and before 建筑

我想要它做什么:

我希望这个信息图标和“基本健美操进阶”在所有设备上都位于顶部而不重叠。

我试过的:

我尝试添加 CardView,从约束布局移动到框架布局等,但似乎没有任何效果,recyclerView 仍然与 header 重叠。

fragment_home.xml

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout 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:id="@+id/homeFrameLayout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#1D1D1B"
    tools:context="com.cuyer.calitracker.View.HomeFragment">

    <androidx.constraintlayout.widget.ConstraintLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        

        <TextView
            android:id="@+id/textView14"
            style="@style/fill_box_textview"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerHorizontal="true"
            android:layout_centerVertical="true"
            android:shadowDx="-4"
            android:shadowDy="-4"
            android:shadowRadius="2"
            android:text="BASIC CALISTHENICS PROGRESSION"
            app:layout_constraintBottom_toTopOf="@+id/recyclerView"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintHorizontal_bias="0.497"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent" />

        <androidx.recyclerview.widget.RecyclerView
            android:id="@+id/recyclerView"
            android:layout_width="match_parent"
            android:layout_height="640dp"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintHorizontal_bias="0.0"
            app:layout_constraintStart_toStartOf="parent" />

        <ImageView
            android:id="@+id/infoImageView"
            android:layout_width="41dp"
            android:layout_height="43dp"
            android:src="@drawable/ic_outline_info_24"
            app:layout_constraintBottom_toTopOf="@+id/recyclerView"
            app:layout_constraintEnd_toStartOf="@+id/textView14"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent" />

    </androidx.constraintlayout.widget.ConstraintLayout>


</FrameLayout>

像这样修改您的布局可能会解决问题

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout 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:id="@+id/homeFrameLayout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#1D1D1B"
    tools:context="com.cuyer.calitracker.View.HomeFragment">

    <androidx.constraintlayout.widget.ConstraintLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <LinearLayout
            android:id="@+id/linearLayout"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:gravity="center_vertical"
            android:orientation="horizontal"
            android:padding="20dp"
            app:layout_constraintTop_toTopOf="parent">

            <ImageView
                android:id="@+id/infoImageView"
                android:layout_width="41dp"
                android:layout_height="43dp"
                android:layout_marginEnd="20dp"
                android:src="@drawable/ic_outline_info_24"
                app:layout_constraintBottom_toTopOf="@+id/recyclerView"
                app:layout_constraintEnd_toStartOf="@+id/textView14"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toTopOf="parent" />

            <TextView
                android:id="@+id/textView14"
                style="@style/fill_box_textview"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_centerHorizontal="true"
                android:layout_centerVertical="true"
                android:layout_weight="1"
                android:shadowDx="-4"
                android:shadowDy="-4"
                android:shadowRadius="2"
                android:text="BASIC CALISTHENICS PROGRESSION"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintHorizontal_bias="0.497"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toTopOf="parent" />


        </LinearLayout>


        <androidx.recyclerview.widget.RecyclerView
            android:id="@+id/recyclerView"
            android:layout_width="match_parent"
            android:layout_height="0dp"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintHorizontal_bias="0.0"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@+id/linearLayout" />


    </androidx.constraintlayout.widget.ConstraintLayout>


</FrameLayout>