前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >CardView使用及属性

CardView使用及属性

作者头像
yechaoa
发布2022-06-10 12:18:41
6700
发布2022-06-10 12:18:41
举报
文章被收录于专栏:移动开发专栏

使用非常简单,属性不多,常用的更是没几个,自带就有阴影和圆角了

代码语言:javascript
复制
compile 'com.android.support:cardview-v7:25.3.1'
代码语言:javascript
复制
<android.support.v7.widget.CardView
        android:id="@+id/cardView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_margin="10dp"
        android:foreground="?android:attr/selectableItemBackground"
        app:cardBackgroundColor="#1296db"
        app:cardCornerRadius="10dp"
        app:cardElevation="10dp"
        app:contentPadding="10dp">

        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:text="@string/card_view"
            android:textColor="#fff"/>

    </android.support.v7.widget.CardView>

常用的两个属性:

app:cardBackgroundColor设置背景颜色

app:contentPadding设置内容padding

其他:

app:cardCornerRadius这是设置圆角大小 app:cardElevation这是设置z轴的阴影 app:cardMaxElevation这是设置z轴的最大高度值 app:cardUseCompatPadding是否使用CompatPadding app:cardPreventCornerOverlap是否使用PreventCornerOverlap app:contentPaddingLeft 设置内容的左padding app:contentPaddingTop 设置内容的上padding app:contentPaddingRight 设置内容的右padding app:contentPaddingBottom 设置内容的底padding

Gituhb:https://github.com/yechaoa/MaterialDesign

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2017-09-29,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档