卡片浏览 Lollipop 前设备在长按或单击通常会在具有 Lollipop 或更高版本的设备中显示波纹的位置时显示难看的黑色渐变。
这是我的 CardView XML
<android.support.v7.widget.CardView
android:id="@+id/cardview1"
android:layout_width="match_parent"
android:layout_height="match_parent"
style="@style/swipe_section_padding"
android:foreground="?android:attr/selectableItemBackground"
android:clickable="true"
card_view:cardCornerRadius="3dp"
card_view:cardElevation="0dp"
card_view:contentPadding="0dp">
<RelativeLayout ...
</android.support.v7.widget.CardView>
最佳答案
尝试添加 card_view:cardUseCompatPadding="false"属性,
useCompatPadding boolean: true> if CardView should add padding for the shadows on platforms Lollipop and above.
查看cardview:cardUseCompatPadding
<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="wrap_content"
android:layout_margin="10dip" >
<android.support.v7.widget.CardView
android:id="@+id/cardview1"
android:layout_width="match_parent"
android:layout_height="100dp"
android:clickable="true"
android:foreground="?android:attr/selectableItemBackground"
card_view:cardCornerRadius="3dp"
card_view:cardElevation="2dp"
card_view:cardUseCompatPadding="false"
card_view:contentPadding="0dp" >
</android.support.v7.widget.CardView >
</LinearLayout >
关于android - CardView 在前 Lollipop 设备中显示黑色(不太好看)阴影,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37387830/