Java 布局预览显示带有协调器布局的空白屏幕

Java 布局预览显示带有协调器布局的空白屏幕,java,android,xml,android-studio,gradle,Java,Android,Xml,Android Studio,Gradle,我得到了xml代码(带有drawables…),并在我的项目中实现了它,但它不起作用 下面是xml代码 <?xml version="1.0" encoding="utf-8"?> <androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android

我得到了xml代码(带有drawables…),并在我的项目中实现了它,但它不起作用

下面是xml代码

<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout 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:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true"
    android:background="@color/profileBackground">

    <com.google.android.material.appbar.AppBarLayout
        android:id="@+id/app_bar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:fitsSystemWindows="true"
        >

        <com.google.android.material.appbar.CollapsingToolbarLayout
            android:id="@+id/toolbar_layout"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:fitsSystemWindows="true"
            app:contentScrim="@color/profilePrimaryDark"
            app:layout_scrollFlags="scroll|exitUntilCollapsed"
            app:toolbarId="@+id/toolbar"
            app:expandedTitleMarginEnd="64dp"
            app:expandedTitleMarginStart="48dp"
            >

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_centerInParent="true"
                android:gravity="center_horizontal"
                android:orientation="vertical"
                android:id="@+id/linearLayout"
                android:background="@drawable/profile_bk">

                <ImageView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:src="@drawable/profile_round" />

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="\@appsnippuser"
                    android:textSize="28dp"
                    android:textStyle="bold"/>

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="developer@appsnipp.com"
                    android:textSize="12dp"
                    android:textStyle="bold"/>

                <RelativeLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:gravity="center"
                    android:layout_gravity="bottom"
                    android:layout_marginTop="20dp"
                    android:background="@color/profileBackground">

                    <View
                        android:layout_alignParentTop="true"
                        android:layout_width="match_parent"
                        android:layout_height="30dp"
                        android:background="@drawable/profile_bk"/>

                </RelativeLayout>

            </LinearLayout>

            <android.support.v7.widget.Toolbar
                android:id="@+id/toolbar"
                android:layout_width="match_parent"
                android:layout_height="?attr/actionBarSize"
                app:layout_collapseMode="pin"
                 />

        </com.google.android.material.appbar.CollapsingToolbarLayout>
    </com.google.android.material.appbar.AppBarLayout>

    <include layout="@layout/content_profile" />


</androidx.coordinatorlayout.widget.CoordinatorLayout>

我尝试在gradle中更改许多版本,但仍然不起作用

可能也是styles.xml中的问题,因为出现错误,我无法发布它


“看起来您的帖子大部分是代码;请添加更多详细信息。”

我认为这对您的XML不重要。请查看没有项目的Coordinator布局是否有效。我认为这对您的XML不重要。请查看没有项目的Coordinator布局是否有效。
<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout 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:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true"
    android:background="@color/profileBackground">

    <com.google.android.material.appbar.AppBarLayout
        android:id="@+id/app_bar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:fitsSystemWindows="true"
        >

        <com.google.android.material.appbar.CollapsingToolbarLayout
            android:id="@+id/toolbar_layout"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:fitsSystemWindows="true"
            app:contentScrim="@color/profilePrimaryDark"
            app:layout_scrollFlags="scroll|exitUntilCollapsed"
            app:toolbarId="@+id/toolbar"
            app:expandedTitleMarginEnd="64dp"
            app:expandedTitleMarginStart="48dp"
            >

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_centerInParent="true"
                android:gravity="center_horizontal"
                android:orientation="vertical"
                android:id="@+id/linearLayout"
                android:background="@drawable/profile_bk">

                <ImageView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:src="@drawable/profile_round" />

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="\@appsnippuser"
                    android:textSize="28dp"
                    android:textStyle="bold"/>

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="developer@appsnipp.com"
                    android:textSize="12dp"
                    android:textStyle="bold"/>

                <RelativeLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:gravity="center"
                    android:layout_gravity="bottom"
                    android:layout_marginTop="20dp"
                    android:background="@color/profileBackground">

                    <View
                        android:layout_alignParentTop="true"
                        android:layout_width="match_parent"
                        android:layout_height="30dp"
                        android:background="@drawable/profile_bk"/>

                </RelativeLayout>

            </LinearLayout>

            <android.support.v7.widget.Toolbar
                android:id="@+id/toolbar"
                android:layout_width="match_parent"
                android:layout_height="?attr/actionBarSize"
                app:layout_collapseMode="pin"
                 />

        </com.google.android.material.appbar.CollapsingToolbarLayout>
    </com.google.android.material.appbar.AppBarLayout>

    <include layout="@layout/content_profile" />


</androidx.coordinatorlayout.widget.CoordinatorLayout>