我在 XML 中的颜色未反映在实际布局中

My color in XML not reflecting in actual layout

我的 XML 看起来像这样,

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"

    android:layout_width="match_parent"
    android:layout_height="match_parent"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:background="@drawable/blackboard"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin">
    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:id="@+id/scroll_view_qr_lost">
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_marginBottom="50dp"
            android:orientation="vertical">
            <android.support.v7.widget.CardView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:padding="10dp"
                android:layout_margin="15dp"
                android:background="#ccc"
                android:orientation="horizontal">
                <EditText
                    android:layout_width="match_parent"
                    android:layout_margin="15dp"
                    android:textColor="#222"
                    android:hint="Type School Name * "
                    android:id="@+id/school_name_activity_lost_qr"
                    android:textColorHint="#6d0d"
                    android:gravity="center"
                    android:layout_height="wrap_content" />
            </android.support.v7.widget.CardView>

            <android.support.v7.widget.CardView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:padding="10dp"
                android:layout_margin="15dp"
                android:background="#ccc"
                android:orientation="horizontal">
                <EditText
                    android:layout_width="match_parent"
                    android:layout_margin="15dp"
                    android:textColor="#222"

                    android:hint="Type Student's Name * "
                    android:id="@+id/student_name_activity_lost_qr"
                    android:textColorHint="#6d0d"
                    android:gravity="center"
                    android:layout_height="wrap_content" />
            </android.support.v7.widget.CardView>

            <android.support.v7.widget.CardView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:padding="10dp"
                android:layout_margin="15dp"
                android:background="#ccc"
                android:orientation="horizontal">
                <EditText
                    android:layout_width="match_parent"
                    android:layout_margin="15dp"
                    android:textColor="#222"
                    android:hint="Type Student's Class * "
                    android:id="@+id/class_no_activity_lost_qr"
                    android:textColorHint="#6d0d"
                    android:gravity="center"
                    android:layout_height="wrap_content" />
            </android.support.v7.widget.CardView>

            <android.support.v7.widget.CardView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:padding="10dp"
                android:layout_margin="15dp"
                android:background="#000"
                android:orientation="horizontal">
                <EditText
                    android:layout_width="match_parent"
                    android:layout_margin="15dp"
                    android:hint="Type Section (If any)  "
                    android:textColor="#222"
                    android:id="@+id/student_section_activity_lost_qr"
                    android:textColorHint="#6d0d"
                    android:gravity="center"
                    android:layout_height="wrap_content" />
            </android.support.v7.widget.CardView>
            <android.support.v7.widget.CardView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:padding="10dp"
                android:layout_margin="15dp"
                android:background="#ccc"
                android:orientation="horizontal">
                <EditText
                    android:layout_width="match_parent"
                    android:layout_margin="15dp"
                    android:hint="Type Student's Roll No * "
                    android:id="@+id/student_roll_no_activity_lost_qr"
                    android:textColorHint="#6d0d"
                    android:gravity="center"
                    android:textColor="#222"
                    android:inputType="number"
                    android:layout_height="wrap_content" />
            </android.support.v7.widget.CardView>

            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="* fields must be entered,  \nPlease press the blue floating button to submit. "
                android:gravity="center"
                android:layout_marginBottom="10dp"
                android:textColor="#ccc"/>

            <android.support.design.widget.FloatingActionButton
                android:id="@+id/fab_submit_lost_qr_application"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                android:clickable="true"
                android:layout_alignParentBottom="true"
                app:backgroundTint="@color/colorPrimaryii"
                android:layout_centerInParent="true"
                android:layout_margin="@dimen/fab_margin"
                android:src="@android:drawable/ic_menu_send" />


        </LinearLayout>

    </ScrollView>

</RelativeLayout>

我的屏幕应该是这样的。

但我在设备中的实际屏幕是这样的,

所以有人可以建议我的程序出了什么问题吗?

P.S。颜色之前工作得很好。

CardView 似乎使用了不同的属性来设置背景颜色。

尝试使用 app:cardBackgroundColor="#ccc"

尝试:

card_view:cardBackgroundColor="#ccc"

记得声明:

xmlns:card_view="http://schemas.android.com/apk/res-auto"

您需要使用卡片视图的应用程序工具,因此只需更改 app:cardbackgroundcolor="#ccc" 而不是 android :background="#ccc"