此文章作为笔记,摘自:ShapedImageView

感谢作者的分享,对开发很有帮助!


  • 简洁,不到100行代码
  • 支持圆形圆角矩形
  • 支持TransitionDrawable

一、studio

dependencies

compile 'cn.gavinliu.android.lib:ShapedImageView:0.4'

二、eclipse

新建class 你懂得 下载https://github.com/gavinliu/ShapedImageView/blob/master/ShapedImageView/src/main/java/cn/gavinliu/android/lib/shapedimageview/ShapedImageView.java

attr

<?xml version="1.0" encoding="utf-8"?><resources>    <declare-styleable name="ShapedImageView">        <attr name="shape_mode" format="enum">            <enum name="round_rect" value="1" />            <enum name="circle" value="2" />        </attr>        <attr name="round_radius" format="dimension" />    </declare-styleable></resources>

在Layout文件 头上加

xmlns:app="http://schemas.android.com/apk/res-auto"

Circle

<cn.gavinliu.android.lib.shapedimageview.ShapedImageView    android:id="@+id/image1"    android:layout_width="200dp"    android:layout_height="200dp"    android:layout_centerInParent="true"    app:shape_mode="circle" />

Round Rect

<cn.gavinliu.android.lib.shapedimageview.ShapedImageView    android:id="@+id/image2"    android:layout_width="200dp"    android:layout_height="200dp"    android:layout_centerInParent="true"    app:round_radius="20dp"    app:shape_mode="round_rect" />



更多相关文章

  1. Android(安卓)studio 升级Android(安卓)Support Repository(46.0
  2. 自定义控件二: Paint Canvar 画几何图形
  3. Android(安卓)中View.onDraw(Canvas canvas)的使用方法
  4. Google VR SDK for Android(1)-introduction(介绍)
  5. Android(安卓)Canvas 说明
  6. Android(安卓)DeepLink
  7. Android串口通信封装之OkUSB
  8. android支持多分辨率屏幕
  9. Android实现全屏截图或长截屏功能

随机推荐

  1. (lintcode)第18题 带重复元素的子集
  2. (lintcode)第463题整数排序
  3. (lintcode)第8题旋转字符串
  4. (lintcode)第20题 骰子求和
  5. (六)高并发redis学习笔记:redis的RDB持久化
  6. (lintcode)第7题二叉树的序列化和反序列
  7. (lintcode)第22题 平面列表
  8. Mybatis创建SqlSession的源码分析
  9. (lintcode)第15题 全排列(没有重复数字)
  10. (lintcode)第17题 子集