您的位置:首页 > 移动开发 > Android开发

CardView 添加背景图片、改变颜色、水波纹效果的方法

2016-08-05 18:01 2371 查看
在这里记录一下使用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"
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  android 布局