0

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>

Kofi
  • 45
  • 6
  • can you please explain what is excelity issue ? – milan pithadia Feb 25 '21 at 13:34
  • 1
    try -> cardBackgroundColor instance of background or backgrounTint app:cardBackgroundColor="@android:color/holo_red_dark" – milan pithadia Feb 25 '21 at 13:42
  • Yh I have tried all that. When I change the opacity of the colour, the issue in the image happens but when the opacity is at 100, it just fills the card. I want the back of the card to be the same as the bothers. – Kofi Feb 25 '21 at 13:59

1 Answers1

0

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"

Shay Kin
  • 2,539
  • 3
  • 15
  • 22