我有一个CardView,它的背景是@color/clolor_ffffff,但在手机上,cardView的背景是灰色的...??!!
我在另一个活动上使用了cardView的xml代码,它是正常的。背景色为ffffff。但是当我将相同的代码复制到另一个片段时,事情发生了这样的变化。
我不知道为什么。
请帮帮me..thx..
代码如下:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView
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="wrap_content"
android:layout_marginBottom="@dimen/dp_4"
android:layout_marginLeft="@dimen/dp_8"
android:layout_marginRight="@dimen/dp_8"
android:layout_marginTop="@dimen/dp_4"
android:background="@color/color_ffffff"
android:clickable="true"
android:foreground="?android:attr/selectableItemBackground"
app:cardCornerRadius="@dimen/dp_4">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingBottom="@dimen/dp_8"
android:paddingRight="@dimen/dp_16"
android:paddingTop="@dimen/dp_8">
<ImageView
android:id="@+id/iv_avatar"
android:layout_width="@dimen/dp_48"
android:layout_height="@dimen/dp_48"
android:layout_gravity="center_vertical"
android:layout_marginLeft="@dimen/dp_8"
android:background="@drawable/ic_account_circle_grey_400_48dp"/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:orientation="vertical"
android:paddingLeft="@dimen/dp_8">
<TextView
android:id="@+id/tv_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="end"
android:maxLines="2"
android:textColor="@color/color_444444"
android:textSize="@dimen/sp_14"
tools:text="Jinks"/>
<TextView
android:id="@+id/tv_mobile"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_8"
android:ellipsize="end"
android:maxLines="1"
android:textColor="@color/color_444444"
android:textSize="@dimen/sp_14"
tools:text="011-11111111"/>
</LinearLayout>
</LinearLayout>
</android.support.v7.widget.CardView>但是如果我使用app:cardBackgroundColor="@color/color_ffffff",cardView的背景是正常的。但是,如果我这样做了,android:foreground="?android:attr/selectableItemBackground"在电话里看不清楚。
我没有在java中使用setBackground的代码。
有错误的颜色图片:gray backgroundColor
发布于 2018-11-21 14:50:37
我使用app:cardBackgroundColor=“@color/白色”
在值/颜色创建中
https://stackoverflow.com/questions/49211784
复制相似问题