首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >CardView BackgroundColor

CardView BackgroundColor
EN

Stack Overflow用户
提问于 2018-03-11 01:11:53
回答 1查看 839关注 0票数 0

我有一个CardView,它的背景是@color/clolor_ffffff,但在手机上,cardView的背景是灰色的...??!!

我在另一个活动上使用了cardView的xml代码,它是正常的。背景色为ffffff。但是当我将相同的代码复制到另一个片段时,事情发生了这样的变化。

我不知道为什么。

请帮帮me..thx..

代码如下:

代码语言:javascript
复制
<?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

EN

回答 1

Stack Overflow用户

发布于 2018-11-21 14:50:37

我使用app:cardBackgroundColor=“@color/白色”

在值/颜色创建中

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/49211784

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档