cardView的使用

CradView的属性和简单使用

文档上是这样介绍的:
A FrameLayout with a rounded corner background and shadow.
cradview是一个带圆角背景和阴影的framelayout。
CardView uses elevation property on Lollipop for shadows and falls back to a custom emulated shadow implementation on older platforms.
CardView在Lollipop(棒棒糖 5.0)上使用高度属性作为阴影,并落回到旧平台上的自定义模拟阴影实现。

XML属性

app:cardBackgroundColor CardView背景颜色。

app:cardCornerRadius CardView转角半径。

app:cardElevation CardViewZ轴的阴影。

app:cardMaxElevation CardView最大Z轴的阴影。

app:cardPreventCornerOverlap 添加填充到CardView在V20之
前,以防止卡的内容和圆角之间的交叉点。

app:cardUseCompatPadding 在API V21 +添加填充,以及有与以前的版本相同的测量。

app:contentPadding 设置CradView内容的padding。

app:contentPaddingBottom 设置CradView内容的底padding。

app:contentPaddingLeft 设置CradView内容的左padding。

app:contentPaddingRight 设置CradView内容的右padding。

app:contentPaddingTop 设置CradView内容的上padding。

使用也特别简单,直接上代码

<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:cardBackgroundColor="@color/white"
    app:cardCornerRadius="@dimen/base4dp">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">
        <ImageView
            android:layout_width="match_parent"
            android:layout_height="@dimen/base140dp"
            android:scaleType="fitXY" />
            <TextView
                android:layout_width="match_parent"
                android:layout_height="@dimen/base40dp"
                android:gravity="center"
                android:textColor="@color/strategy_text_item"
                android:textSize="@dimen/base13dp"
                android:maxLines="1"
                android:ellipsize="end"/>
    </LinearLayout>
</android.support.v7.widget.CardView>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值