Android 为什么我的布局像这样?这是我的XML文件
这是我的 和XML代码首先我使用线性布局,然后是卡片视图和其他视图,所以为什么我的视图覆盖问题出在哪里请观看AVD图片并告诉我错误出在哪里。很抱歉英语不好Android 为什么我的布局像这样?这是我的XML文件,android,xml,android-layout,Android,Xml,Android Layout,这是我的 和XML代码首先我使用线性布局,然后是卡片视图和其他视图,所以为什么我的视图覆盖问题出在哪里请观看AVD图片并告诉我错误出在哪里。很抱歉英语不好 <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/item_linerLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="5dp">
<androidx.cardview.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:cardElevation="10dp">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="10dp">
<TextView
android:id="@+id/item_id"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="1"
android:textSize="36sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/item_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Title"
app:layout_constraintStart_toEndOf="@+id/item_id"
app:layout_constraintTop_toTopOf="@+id/item_id" />
<TextView
android:id="@+id/item_AuthorName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Author"
app:layout_constraintStart_toStartOf="@+id/item_title"
app:layout_constraintTop_toBottomOf="@+id/item_title" />
<TextView
android:id="@+id/item_pages"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="3dp"
android:text="100"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.cardview.widget.CardView>
</LinearLayout>
尝试在根布局中使用android:fitsystemwindows=“true”
(在线性布局中)。我建议您阅读本文以了解系统重叠。我希望这会有所帮助)我已经删除了冗余的线性布局
父项,并制作了cardwiew
父项。此外,您的TextView
与id项页面没有重叠
<androidx.cardview.widget.CardView
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="wrap_content"
android:layout_margin="5dp"
app:cardElevation="10dp">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="10dp">
<TextView
android:id="@+id/item_id"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="1"
android:textSize="36sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/item_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:text="Title"
app:layout_constraintBottom_toTopOf="@id/item_AuthorName"
app:layout_constraintStart_toEndOf="@+id/item_id" />
<TextView
android:id="@+id/item_AuthorName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="4dp"
android:text="Author"
app:layout_constraintBottom_toBottomOf="@id/item_id"
app:layout_constraintStart_toStartOf="@+id/item_title" />
<TextView
android:id="@+id/item_pages"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="3dp"
android:text="100"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.cardview.widget.CardView>
您能告诉我什么是重叠吗?先生,最后一个textView id-=“@+id/item_pages”是重叠的。您已将最后一个textView约束为父级。将约束更改为app:layout\u constraintotop\u toBottomOf=“@+id/item\u AuthorName”。我以为您想禁用状态栏重叠,对于文本视图(item\u页面),只需使用app:layout\u constraintBottom\u toBottomOf=“parent”app:layou\u constraintEnd\u toEndOf=“parent”。app:layout\u constraintop\u toTopOf=“parent”