透明CardView子阴影不出现
Transparent CardView Child Shadow Does Not Appear
我有一个 CardView
,cardBackgroundColor
设置为透明。并且 cardElevation
设置为 3dp
在 CardView
中有一个 ImageView
。我想知道为什么 ImageView
.
上没有阴影
注意:我特意将 ImageView
包裹在 CardView
中以在 Pre Lollipop 设备上生成阴影,但它似乎不起作用。
有什么想法吗?
Set padding to parent view of card view to 3dp.
Like,
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="8dp"
android:background="@android:color/white">
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:elevation="8dp"
android:id="@+id/card1">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#FFFFFF"
android:orientation="horizontal">
<ImageView
android:id="@+id/imgCard"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_margin="10dp"
android:src="@drawable/add_contact" />
<TextView
android:id="@+id/tvColor"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Card View" />
</LinearLayout>
</android.support.v7.widget.CardView>
</RelativeLayout>
我有一个 CardView
,cardBackgroundColor
设置为透明。并且 cardElevation
设置为 3dp
在 CardView
中有一个 ImageView
。我想知道为什么 ImageView
.
注意:我特意将 ImageView
包裹在 CardView
中以在 Pre Lollipop 设备上生成阴影,但它似乎不起作用。
有什么想法吗?
Set padding to parent view of card view to 3dp.
Like,
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="8dp"
android:background="@android:color/white">
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:elevation="8dp"
android:id="@+id/card1">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#FFFFFF"
android:orientation="horizontal">
<ImageView
android:id="@+id/imgCard"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_margin="10dp"
android:src="@drawable/add_contact" />
<TextView
android:id="@+id/tvColor"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Card View" />
</LinearLayout>
</android.support.v7.widget.CardView>
</RelativeLayout>