title: How set background image and fit that image entire card for card view in Android?
body: <p>Here I am trying to fit the entire image as the background for card view. but it takes some space as shown in the picture. I tried <code>android:scaleType=&quot;centerCrop&quot;</code> and <code>fitXY</code> and others also but it not responding. In attached image violet color represents empty space that occupied. I need that spaces need to occupied with the background image. Here is my code.</p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
  &lt;androidx.cardview.widget.CardView xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
      xmlns:app=&quot;http://schemas.android.com/apk/res-auto&quot;
      xmlns:tools=&quot;http://schemas.android.com/tools&quot;
      android:layout_width=&quot;wrap_content&quot;
      android:layout_height=&quot;wrap_content&quot;
      app:cardBackgroundColor=&quot;@color/voilet&quot;&gt;
  
      &lt;androidx.constraintlayout.widget.ConstraintLayout
          android:layout_width=&quot;match_parent&quot;
          android:layout_height=&quot;match_parent&quot;&gt;
  
          &lt;ImageView
              android:id=&quot;@+id/application_ads_image&quot;
              android:layout_width=&quot;match_parent&quot;
              android:layout_height=&quot;match_parent&quot;
              android:scaleType=&quot;centerInside&quot;
              android:src=&quot;@drawable/app_ads_background&quot;
              app:layout_constraintBottom_toBottomOf=&quot;parent&quot;
              app:layout_constraintEnd_toEndOf=&quot;parent&quot;
              app:layout_constraintHorizontal_bias=&quot;0.0&quot;
              app:layout_constraintStart_toStartOf=&quot;parent&quot;
              app:layout_constraintTop_toTopOf=&quot;parent&quot;
              app:layout_constraintVertical_bias=&quot;1.0&quot; /&gt;
  
          &lt;Button
              android:id=&quot;@+id/application_ads_install_button&quot;
              android:layout_width=&quot;74dp&quot;
              android:layout_height=&quot;34dp&quot;
              android:layout_marginEnd=&quot;48dp&quot;
              android:background=&quot;@color/voilet&quot;
              android:text=&quot;@string/application_ads_install&quot;
              android:textColor=&quot;@color/white&quot;
              android:textStyle=&quot;bold&quot;
              app:layout_constraintBottom_toBottomOf=&quot;parent&quot;
              app:layout_constraintEnd_toEndOf=&quot;@+id/application_ads_image&quot;
              app:layout_constraintTop_toTopOf=&quot;@+id/application_ads_image&quot;
              app:layout_constraintVertical_bias=&quot;0.674&quot; /&gt;
  
          &lt;TextView
              android:id=&quot;@+id/application_ads_review&quot;
              android:layout_width=&quot;wrap_content&quot;
              android:layout_height=&quot;wrap_content&quot;
              android:text=&quot;@string/application_ads_review&quot;
              android:textColor=&quot;@color/white&quot;
              app:layout_constraintBottom_toBottomOf=&quot;@+id/application_ads_image&quot;
              app:layout_constraintEnd_toStartOf=&quot;@+id/application_ads_install_button&quot;
              app:layout_constraintHorizontal_bias=&quot;0.27&quot;
              app:layout_constraintStart_toStartOf=&quot;parent&quot;
              app:layout_constraintTop_toBottomOf=&quot;@+id/application_ads_name&quot;
              app:layout_constraintVertical_bias=&quot;0.567&quot; /&gt;
  
          &lt;TextView
              android:id=&quot;@+id/application_ads_name&quot;
              android:layout_width=&quot;wrap_content&quot;
              android:layout_height=&quot;wrap_content&quot;
              android:layout_marginTop=&quot;40dp&quot;
              android:text=&quot;Zira&quot;
              android:textColor=&quot;@color/white&quot;
              app:layout_constraintEnd_toEndOf=&quot;@+id/application_ads_image&quot;
              app:layout_constraintHorizontal_bias=&quot;0.176&quot;
              app:layout_constraintStart_toStartOf=&quot;parent&quot;
              app:layout_constraintTop_toTopOf=&quot;parent&quot; /&gt;
      &lt;/androidx.constraintlayout.widget.ConstraintLayout&gt;
  
  &lt;/androidx.cardview.widget.CardView&gt;
  </code></pre>
  <p><a href="https://i.stack.imgur.com/6RDvm.jpg" rel="nofollow noreferrer">This is <strong>Image</strong> of my output as per my code</a></p>