一、在https://github.com/vinc3m1/RoundedImageView下载项目,
二、由于此文件是一个android studio下编写的项目,所以如果想要在eclipse下实现,
应该引入picasso-2.5.2.jar support-annotations-23.0.0.jar包
,然后就是将里面的文件一个个拷入eclipse下对应的文件夹下
三、使用
在XML文件中使用方法:
<com.makeramen.roundedimageview.RoundedImageView xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@+id/imageView1" android:src="@drawable/photo1" android:scaleType="fitCenter" app:riv_corner_radius="30dip"//该属性可以设置圆角弧度 app:riv_border_width="2dip"//该属性可以设置边框宽度 app:riv_border_color="#333333"//该属性可以设置边框颜色 app:riv_mutate_background="true" app:riv_tile_mode="repeat" app:riv_oval="true" />在Java文件中使用:
RoundedImageView riv = new RoundedImageView(context); riv.setScaleType(ScaleType.CENTER_CROP); riv.setCornerRadius((float) 10); riv.setBorderWidth((float) 2); riv.setBorderColor(Color.DKGRAY); riv.mutateBackground(true); riv.setImageDrawable(drawable); riv.setBackground(backgroundDrawable); riv.setOval(true); riv.setTileModeX(Shader.TileMode.REPEAT); riv.setTileModeY(Shader.TileMode.REPEAT);