圆角Imageview

来源:互联网 发布:博优软件官网 编辑:程序博客网 时间:2024/06/03 20:04

             001.也是项目需求,我们的UI妹子设计了圆角图片,我开始准备自定义结果自己能力有限废了好大劲还没达到效果,之后就去搜索,开源强大,还真简单实现图片圆角

           002.cardview简单实现图片圆角处理:cardview是Android5.0出的一个新控件,直接包裹一个Imageview实现圆角

                   添加依赖:

                             compile 'com.android.support:cardview-v7:25.3.1'   

                   xml代码如下,就可以直接运行看效果

<?xml version="1.0" encoding="utf-8"?><LinearLayout    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"    >    <android.support.v7.widget.CardView        android:id="@+id/cv"        android:layout_width="match_parent"        android:layout_height="200dp"        android:layout_margin="10dp"        app:cardElevation="3dp"        app:cardCornerRadius="18dp">        <ImageView            android:id="@+id/fragment_home_info_item_img"            android:layout_width="match_parent"            android:layout_height="match_parent"            android:scaleType="centerCrop"            android:src="@drawable/abc"            />    </android.support.v7.widget.CardView></LinearLayout>
     

         属性设置:

  • CardView_cardBackgroundColor 设置背景色
  • CardView_cardCornerRadius 设置圆角大小
  • CardView_cardElevation 设置z轴阴影
  • CardView_cardMaxElevation 设置z轴最大高度值
  • CardView_cardUseCompatPadding 是否使用CompadPadding
  • CardView_cardPreventCornerOverlap 是否使用PreventCornerOverlap
  • CardView_contentPadding 内容的padding
  • CardView_contentPaddingLeft 内容的左padding
  • CardView_contentPaddingTop 内容的上padding
  • CardView_contentPaddingRight 内容的右padding
  • CardView_contentPaddingBottom 内容的底padding

        大家可以根据自己需求扩展!!

     

            003.github圆角神器:github圆角链接