<SPAN xmlns="http:///1999/xhtml">package ;
import ;
import ;
import ;
import ;
import ;
import ;
import ;
import ;
public class DrawImageView extends ImageView {
private final Paint paint;
private final Context context;
public DrawImageView(Context context, AttributeSet attrs) {
super(context, attrs);
// TODO Auto-generated constructor stub
= context;
= new Paint();
(true); //Extinguish the aliasing
(); //Draw hollow circles or hollow rectangles
}
@Override
protected void onDraw(Canvas canvas) {
// TODO Auto-generated method stub
int center = getWidth()/2;
int innerCircle = dip2px(context, 83); //The radius of the inner circle
int ringWidth = dip2px(context, 10); //Ring width
// The first method to draw a circle
//Draw the inner circle
(255, 138, 43, 226);
(2);
(center, center, innerCircle, );
//Draw the circle
(255, 138, 43, 226);
(ringWidth);
(center, center, innerCircle + 1 +ringWidth/2, );
//Draw the outer circle
(255, 138, 43, 226);
(2);
(center, center, innerCircle + ringWidth, );
(canvas);
}
/* Convert from dp to px (pixel) based on the resolution of the phone */
public static int dip2px(Context context, float dpValue) {
final float scale = ().getDisplayMetrics().density;
return (int) (dpValue * scale + 0.5f);
}
}
</SPAN>