在这里记录一下使用CardView时用图片作为背景的方法:
<android.support.v7.widget.CardView
….
>
/*首先设置imageView作为图片的背景*/
<ImageView
android:layout_width = “match_parent"
android:layout_height = “match_parent"
android:background = “@drawable/background”/>
<
...
/>
</android.support.v7.widget.CardView>
在布局的开始添加ImageView为背景图片就行。
另外:改变 CardView背景颜色要使用:
app:cardBackgroundColor = ""
使用android:background = “” 是无效的
为5.0以上设备添加点击时的水波纹效果使用:
android:foreground = "?attr/selectableItemBackground"