Android 图片圆角的简单方法

package com.jereh.helloworld.activity.ui;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Path;
import android.graphics.RectF;
import android.util.AttributeSet;
import android.widget.ImageView;
/**
* Created by Hh。 on 2016/10/31.
*/
public class UIImageView extends ImageView {
public UIImageView(Context context, AttributeSet attrs) {
super(context, attrs);
}
public UIImageView(Context context) {
super(context);
}
public UIImageView(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
@Override
public void draw(Canvas canvas) {
super.draw(canvas);
}
@Override
protected void onDraw(Canvas canvas) {
Path clipPath = new Path();
int w = this.getWidth();
int h = this.getHeight();
clipPath.addRoundRect(new RectF(0, 0, w, h), 30.0f, 30.0f, Path.Direction.CW);
canvas.clipPath(clipPath);
super.onDraw(canvas);
}
}

  

上一篇:Tomcat Server 原理


下一篇:使用Qpaint在图片上写文字