đơn giản 2 bước để làm cho Android CardView
trong suốt.
Đặt app:cardBackgroundColor="@android:color/transparent"
. Đây là thuộc tính CardView
để đặt nền.
Đặt app:cardElevation="0dp"
để xóa bóng.
Ví dụ, đây là mã xml nhỏ để tạo minh bạch CardView
<android.support.v7.widget.CardView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/card_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:cardBackgroundColor="@android:color/transparent"
app:cardElevation="0dp" />
Lưu ý: Không sử dụng
setBackground
. Sử dụng app:cardBackgroundColor
để thay thế.
Nguồn
2017-08-19 09:12:11
bạn đã thử 'android: background = "@ android: màu/minh bạch" ' – Psypher
bạn nên sử dụng _cardBackgroundColor_? – harism
android: background = "@ android: color/transparent" không hoạt động Tôi không sử dụng backgroundColor vì nó không có tùy chọn trong suốt – mac229