generate shotcut
constraints
Log
Log
invalidate
force to redraw, if you call it in onDraw()
, it will be called again and again, like a loop.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
| package uno.bai.tim.test;
import android.content.Context; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.Paint; import android.support.annotation.Nullable; import android.util.AttributeSet; import android.view.MotionEvent; import android.view.View;
/** * Created by tim on 12/03/18. */
public class EasyView extends View {
float x =50; float y =50;
public EasyView(Context context) { super(context); }
public EasyView(Context context, @Nullable AttributeSet attrs) { super(context, attrs); }
public EasyView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); }
@Override protected void onDraw(Canvas canvas) {
Paint paint = new Paint(); paint.setColor(Color.LTGRAY);
canvas.drawCircle(x,y,20,paint); x++; y++;
invalidate(); //
// super.onDraw(canvas); }
@Override public boolean onTouchEvent(MotionEvent event) { return super.onTouchEvent(event); } }
|