我的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。颜色在早些时候工作得很好。
答案 0 :(得分:2)
看起来CardView使用不同的属性来设置背景颜色。
尝试使用app:cardBackgroundColor =&#34;#ccc&#34;
答案 1 :(得分:1)
您需要使用应用工具进行卡片视图,因此只需更改 app:cardbackgroundcolor =“#ccc”,而不是 android:background =“#ccc”
答案 2 :(得分:0)
尝试:
card_view:cardBackgroundColor="#ccc"
请记住声明:
xmlns:card_view="http://schemas.android.com/apk/res-auto"