簡體   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