-1

I have a cardview that contains an imageview like the screenshot:

enter image description here

Since the image is round I would like to remove the cardview's background so the white square doesn't show.

Here's my code:

  <?xml version="1.0" encoding="utf-8"?>
    <android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        xmlns:card_view="http://schemas.android.com/tools"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        card_view:cardCornerRadius="5dp"
        card_view:cardPreventCornerOverlap="true"
        android:paddingLeft="2.5dp"
        android:paddingRight="2.5dp">

        <android.support.v7.widget.AppCompatImageView
            android:id="@+id/caracteristica_imagen"
            android:layout_width="50dp"
            android:layout_height="50dp"
            android:adjustViewBounds="true"
            android:background="@android:color/transparent"
            android:cropToPadding="true"
            android:elevation="0dp"
            android:scaleType="fitStart"
            android:paddingLeft="2.5dp"
            android:paddingRight="2.5dp" />
    </android.support.v7.widget.CardView>
OneCricketeer
  • 179,855
  • 19
  • 132
  • 245
MauriR
  • 537
  • 10
  • 20

2 Answers2

0
app:cardBackgroundColor="@android:color/transparent"

add this

0

Use in XML

Add xmlns:card_view="http://schemas.android.com/apk/res-auto" in XML

Then

card_view:cardBackgroundColor="@android:color/transparent"

or in Java

cardView.setCardBackgroundColor(Color.TRANSPARENT);
KeLiuyue
  • 8,149
  • 4
  • 25
  • 42