CardView上的透明背景-Android [英] Transparent background on CardView - Android
问题描述
我想在CardView上做透明背景. 我知道backgroundColor但我的布局上有图像.
I want to do transparent background on CardView. I know backgroundColor but i have image on my Layout.
你知道怎么做吗?还是可以作为cardview使用的东西,但我会设置透明背景?
Do you know how do it? Or something which work as cardview but i will set a transparent background?
致谢
推荐答案
将CardView设置为使用cardBackgroundColor
属性删除颜色,使用cardElevation
属性删除阴影.例如:
Setup your CardView to use the cardBackgroundColor
attribute to remove color and cardElevation
attribute to remove the drop shadow. For example:
<android.support.v7.widget.CardView
xmlns:card_view="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/myCardView"
android:layout_width="match_parent"
android:layout_height="match_parent"
card_view:cardBackgroundColor="@android:color/transparent"
card_view:cardElevation="0dp">
有关受支持属性的完整列表,请参见此处: https://developer.android .com/reference/android/support/v7/widget/CardView.html
For a full list of supported attributes see here: https://developer.android.com/reference/android/support/v7/widget/CardView.html
如果您使用的是较旧的API,则需要在CardView
上调用以下两个函数:
If you are using an older API, you will need to call these two functions on your CardView
instead:
myCardView.setCardBackgroundColor(Color.TRANSPARENT);
myCardView.setCardElevation(0);
这篇关于CardView上的透明背景-Android的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!