如何为Android CardView设置半透明背景颜色?

问题描述 投票:0回答:1

我想使用argb颜色设置名片视图的backgroundColor。但是结果是这样的:

enter image description here

<androidx.cardview.widget.CardView
        android:id="@+id/infoCard"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginStart="16dp"
        android:layout_marginTop="8dp"
        android:layout_marginEnd="16dp"
        android:layout_marginBottom="8dp"
        app:cardBackgroundColor="#59448AFF"
        app:cardCornerRadius="8dp">

        <com.google.android.material.textview.MaterialTextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginStart="@dimen/space_16dp"
            android:layout_marginTop="@dimen/space_8dp"
            android:layout_marginEnd="@dimen/space_16dp"
            android:layout_marginBottom="@dimen/space_8dp"
            android:lineSpacingExtra="@dimen/space_4dp"
            android:text="This is a sample text"
            android:textColor="@color/secondaryText"
            android:textSize="16sp" />

    </androidx.cardview.widget.CardView>

有人知道如何解决此问题吗?

android android-cardview cardview
1个回答
0
投票

color.xml内定义

© www.soinside.com 2019 - 2024. All rights reserved.