1: 去github上下载 工程
https://github.com/vinc3m1/RoundedImageView
2: 导入工程
3 在布局中使用它
<com.makeramen.rounded.RoundedImageView
android:id="@+id/imageView1"
android:layout_width=“wrap_content”
android:layout_height=“wrap_content”
android:layout_alignParentTop=“true”
android:layout_alignParentBottom=“true”
android:layout_alignParentRight=“true”
android:layout_alignParentLeft=“true”
android:padding="
10dip"
android:src="@drawable/photo1"
android:scaleType=“center”
makeramen:corner_radius=“30dip”
makeramen:border_width=“2dip”
makeramen:border_color="#333333" />
属性的意义:
makeramen:border_width=“2dip” 表示图片的边框宽度为2个dp
makeramen: corner_radius表示为 图片转圆角的弧度
修改 makeramen:corner_radius=“100dip”
当 corner_radius 设置为100dp 的时候 会呈现为圆形 .
( 注: com.makeramen.rounded.RoundedImageView 控件的宽和高需要相等 )
修改了example中的 rounded_item.xml
<?xml version="1.0" encoding="utf-8"?><RelativeLayout
xmlns:android=“http://schemas.android.com/apk/res/android”
xmlns:makeramen=“http://schemas.android.com/apk/res/com.makeramen.rounded.example”
android:layout_width=“match_parent”
android:layout_height=“200dip”>
<com.makeramen.rounded.RoundedImageView
android:id="@+id/imageView1"
android:layout_width=“200dp”
android:layout_height=“200dp”<