简体   繁体   中英

Can't fully hide android material card background

Image how it looks

Can't fully hide android material card background. I have searched and watched all videos available but nothing has worked so far. I know I could just put something to fill the card but I want to know just in case.

The code:

<com.google.android.material.card.MaterialCardView
android:id="@+id/card"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:backgroundTint="#40000000"
android:clickable="true"
app:cardCornerRadius="30dp"
android:layout_margin="10dp">

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Planner"
android:textAlignment="center"
android:textColor="@color/white"
android:textSize="20sp"
android:fontFamily="@font/nova_bold"/>

<ImageView
android:layout_width="150dp"
android:layout_height="130dp"
android:layout_marginStart="10dp"
android:layout_marginTop="30dp"
android:padding="1dp"
app:srcCompat="@drawable/ic_plan_vec" />

</com.google.android.material.card.MaterialCardView>

please use in your XML app:cardBackgroundColor="@color/yourColor" or in your java code card.setCardBackgroundColor(YourColor); instead of the default setBackgroundColor()

UPDATE

for the opacity change android:backgroundTint="#40000000" by android:alpha="0.4"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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