0

The layout file with the CardView in ConstraintLayout:

<androidx.cardview.widget.CardView
        android:id="@+id/cardview"
        android:layout_width="392dp"
        android:layout_height="0dp"
        app:cardElevation="32dp"
        app:cardBackgroundColor="#000000"
        app:layout_constraintDimensionRatio="H,16:9"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="parent">

    <ImageView
            android:id="@+id/imageView"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:scaleType="centerCrop"
            android:src="@drawable/eagle"
            tools:ignore="contentDescription"/>

</androidx.cardview.widget.CardView>

Here is the result, the left on Android 4.4.2, API 19 V.S. the right on Android 8, api 26. As you can see the result on API 19 is cutting off the image. Anyway to prevent the CardView's attribute cardElevation to cut into the content on API 19 or older? ?

Here is the image url for testing: http://t.wallpaperweb.org/wallpaper/animals/1920x1080/Bald_Eagle_in_Flight_Alaska.jpg

s-hunter
  • 24,172
  • 16
  • 88
  • 130

1 Answers1

0

I think it's not about api level , it's something related to the screen size / density .

Remove this form your ImageView attribute : android:scaleType="centerCrop" and in your cardView set height to wrap_content android:layout_height="wrap_content"

ismail alaoui
  • 5,748
  • 2
  • 21
  • 38