您的位置:首页 > 移动开发 > Android开发

【转载】 android 圆角圆形图片ShapedImageView不到100行代码

2016-04-18 10:22 751 查看
此文章作为笔记,摘自: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" />



内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: