美文网首页
android自定义UI学习

android自定义UI学习

作者: juanxincai | 来源:发表于2016-06-25 00:26 被阅读0次

    import android.content.Context;

    import android.graphics.Canvas;

    import android.graphics.Color;

    import android.graphics.Paint;

    import android.util.AttributeSet;

    import android.view.MotionEvent;

    import android.view.View;

    public class DrawViewextendsView {

    public float currentX=40; 

    public float currentY=50;

    Paint p=new Paint();

    public DrawView(Contextcontext) {

    super(context);

    }

    public DrawView(Contextcontext, AttributeSet set){

    super(context, set);

    }

    @Override

    public voidonDraw(Canvas canvas){

    super.onDraw(canvas);

    p.setColor(Color.GREEN);

    canvas.drawCircle(currentX,currentY,15,p);

    }

    @Override

    public booleanonTouchEvent(MotionEvent event){

    currentX = event.getX();

    currentY= event.getY();

    invalidate();

    return true;

    }

    }

    网页版简书好难用。

    相关文章

      网友评论

          本文标题:android自定义UI学习

          本文链接:https://www.haomeiwen.com/subject/kwhorttx.html