Tôi đã triển khai CardView trong ứng dụng của mình và mọi thứ hoạt động tốt ngoại trừ có một chút đệm xung quanh hình ảnh nếu tôi đặt bán kính vào thẻ.Đệm không cần thiết trong CardView?
Nó xuất hiện như thế này:
Nhưng trong android docs và trong this article hình ảnh mất toàn bộ cardview, vì vậy u có thể giúp tôi đạt được điều đó.
file layout của tôi là như sau:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="8dp">
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="200dp"
card_view:cardBackgroundColor="@android:color/white"
card_view:cardCornerRadius="4dp">
<ImageView
android:id="@+id/media_image_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"/>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:alpha="0.8"
android:background="?attr/colorPrimary"
android:padding="4dp">
<TextView
android:id="@+id/media_download"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:textSize="11sp"/>
<TextView
android:id="@+id/category_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:textColor="@color/primary_text"
android:textSize="12sp"/>
</RelativeLayout>
</android.support.v7.widget.CardView>
</LinearLayout>
Chú ý: Ảnh chụp màn hình được chụp trên một thiết bị pre-kẹo.
bạn có thể vui lòng thử lại mà không có sự 'android: đệm = "4dp" 'trên RelativeLayout của bạn? –