很对不住大家 此代码有问题,这样做出来的原形imageview没有抗锯齿,到这图片边缘模糊 效果如下:
由于项目需要图片要做成圆形的,只能自定义ImageView,下边自定义的ImageView效果如上图,边缘不抗锯齿,模糊
public class RoundImageView extends ImageView {
public RoundImageView(Context context) {
super(context);
// TODO Auto-generated constructor stub
}
public RoundImageView(Context context, AttributeSet attrs) {
super(context, attrs);
}
public RoundImageView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
@Override
protected void onDraw(Canvas canvas) {
Path clipPath = new Path();
int w = this.getWidth();
int h = this.getHeight();
clipPath.addCircle(w / 2, h / 2, w / 2, Path.Direction.CW);
canvas.clipPath(clipPath);
canvas.setDrawFilter(new PaintFlagsDrawFilter(0, Paint.ANTI_ALIAS_FLAG
|