繁体   English   中英

如何使用自定义背景更改我的 cardview 背景?

[英]How do i change my cardview background with a custom background?

我制作了一个 box.xml 文件,它看起来像这样

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item>
    <shape android:shape="rectangle">
        <solid android:color="#FF9800"></solid>
        <corners android:radius="10dp"></corners>
    </shape>
</item>

</selector>

对于我的卡片视图,我添加了android:background="@drawable/box"但颜色没有改变

Cardview 有所有包括形状,颜色,半径

<androidx.cardview.widget.CardView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:cardElevation="10dp"
        app:cardCornerRadius="20dp"
        android:layout_margin="10dp"
        app:cardBackgroundColor="@color/white"
        app:cardMaxElevation="12dp"
        app:cardPreventCornerOverlap="true"
        app:cardUseCompatPadding="true"
        >

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM