Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 为什么我的布局像这样?这是我的XML文件_Android_Xml_Android Layout - Fatal编程技术网

Android 为什么我的布局像这样?这是我的XML文件

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代码首先我使用线性布局,然后是卡片视图和其他视图,所以为什么我的视图覆盖问题出在哪里请观看AVD图片并告诉我错误出在哪里。很抱歉英语不好

<?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”