用户注册



邮箱:

密码:

用户登录


邮箱:

密码:
记住登录一个月忘记密码?

发表随想


还能输入:200字
云代码 - windows phone代码库

圆环交替

2017-03-14 作者: 老四和老三的老二都老大了举报

[windows phone]代码库

public CustomView(Context context, AttributeSet attrs) {
        super(context, attrs);
        TypedArray typedArray=context.obtainStyledAttributes(attrs,R.styleable.customColor);
        /*firstColor=typedArray.getColor(R.styleable.customColor_firstColor, Color.parseColor("#00ff00"));
        secondColor=typedArray.getColor(R.styleable.customColor_secondColor,Color.parseColor("#ff0000"));
        circleWidth=(int)typedArray.getDimension(R.styleable.customColor_circleWidth,10);*/
        typedArray.recycle();
}

protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);
        paint.setAntiAlias(true);
        paint.setStyle(Paint.Style.STROKE);
        paint.setStrokeWidth(circleWidth);
        if(flag){
            paint.setColor(firstColor);
            canvas.drawCircle(getWidth()/2,getHeight()/2,100,paint);
            paint.setColor(secondColor);
            canvas.drawArc(new RectF(getWidth()/2-100,getHeight()/2-100,getWidth()/2+100,getHeight()/2+100),-90,progress,false,paint);
        }else{
            paint.setColor(secondColor);
            canvas.drawCircle(getWidth()/2,getHeight()/2,100,paint);
            paint.setColor(firstColor);
            canvas.drawArc(new RectF(getWidth()/2-100,getHeight()/2-100,getWidth()/2+100,getHeight()/2+100),-90,progress,false,paint);
        }

        /*if(thread==null){
            thread=new MyThread();
            thread.start();
        }*/

    }

class MyThread extends Thread{
        @Override
        public void run() {
            super.run();
            while(true){
                progress+=3;
                if(progress==360){
                    progress=0;
                    if(flag){
                        flag=false;
                    }else{
                        flag=true;
                    }
                }

                postInvalidate();
                try {
                    Thread.sleep(50);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        }
    }


网友评论    (发表评论)

共2 条评论 1/1页

发表评论:

评论须知:

  • 1、评论每次加2分,每天上限为30;
  • 2、请文明用语,共同创建干净的技术交流环境;
  • 3、若被发现提交非法信息,评论将会被删除,并且给予扣分处理,严重者给予封号处理;
  • 4、请勿发布广告信息或其他无关评论,否则将会删除评论并扣分,严重者给予封号处理。


扫码下载

加载中,请稍后...

输入口令后可复制整站源码

加载中,请稍后...