Android 画个圆 淡入淡出
private class SimpleView extends ImageView{ int point_x; int point_y; int radius = 0; public SimpleView(Context context) { super(context); // TODO Auto-generated constructor stub } @Override public boolean onTouchEvent(MotionEvent event) { point_x = (int) event.getX();//获取点击位置 point_y = (int) event.getY(); if (event.getAction() == MotionEvent.ACTION_UP) { upFlag = true; } invalidate(); return true; }; protected void onDraw(android.graphics.Canvas canvas) { alpha -= 3; canvas.drawColor(Color.BLUE); //设置背景色 Paint paint = new Paint(); paint.setColor(Color.WHITE); //设置画笔颜色 paint.setAlpha(alpha); //设置透明度 paint.setStyle(Paint.Style.FILL); paint.setAntiAlias(true); if (upFlag) { ++radius; if (radius > 26) { upFlag = false; radius = 0; alpha = 255; } if (radius == 18) { alpha = 100; } canvas.drawCircle(point_x, point_y, radius, paint); //画圆 invalidate(); } } }
转载至:http://blog.csdn.net/walker02/article/details/7254829