CardView得使用 自带阴影
由于经常写一些listview布局 要求不高 就随便着了个布局来实现 用了
CardView 这个控件 方便之处在于 自带卡片状阴影 缺点就是两边不能最大到无边框 就是一个卡片形状 偷懒用的
还是导入工具类
compile 'com.android.support:cardview-v7:25.0.1'
在布局中使用
<android.support.v7.widget.CardView android:id="@+id/ll_noclick" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginLeft="@dimen/x20" android:layout_marginRight="@dimen/x20" android:background="@color/hui" android:orientation="vertical" app:cardPreventCornerOverlap="true" app:cardUseCompatPadding="true">
上个图 大概样式
CardView三个个主要的属性就是
app:cardElevation="10dp"阴影的大小
和 app:cardCornerRadius="10dp"卡片的圆角大小
app:card_view:contentPadding="5dp" 卡片内容于边距的间隔
通常都是4dp左右,阴影效果如果太大了看起来很丑的哦,这里为了演示所以设置10dp加上
android:foreground="?attr/selectableItemBackground"
效果棒棒哒