zoukankan      html  css  js  c++  java
  • Android进阶篇自定义同心圆View

    /**
     * @author gongchaobin
     * 
     * 圆
     * @version 2012-12-5
     */
    public class RingView extends View {
    
        private Paint paint;
        private Context context;
        private int radius;//半径
        private int color;//颜色值
        
        public RingView(Context context) {
            
            // TODO Auto-generated constructor stub
            this(context, null);
        }
    
        public RingView(Context context, AttributeSet attrs) {
            super(context, attrs);
            // TODO Auto-generated constructor stub
            this.context = context;
            this.paint = new Paint();
            this.paint.setAntiAlias(true); //消除锯齿
        }
    
        @Override
        protected void onDraw(Canvas canvas) {
            // TODO Auto-generated method stub
            int center = getWidth()/2;
            
            //绘制内圆
            paint.setStyle(Paint.Style.FILL);
            paint.setColor(color);
            canvas.drawCircle(center,center, radius, this.paint);
            
            //绘制外圆(空心)
            paint.setStyle(Paint.Style.STROKE);
            paint.setColor(Color.BLACK);
            canvas.drawCircle(center,center, 60, this.paint);
            super.onDraw(canvas);
        }
    
        public int getRadius() {
            return radius;
        }
    
        public void setRadius(int radius) {
            this.radius = radius;
        }
    
        public int getColor() {
            return color;
        }
    
        public void setColor(int color) {
            this.color = color;
        }
        
    }
  • 相关阅读:
    javaScript学习日记 1 数组
    总结css中单位px和em,rem的区别
    读书摘要
    读书摘要
    各种官方网站汇集
    js相关参考资料
    Node相关参考资料
    Angular【学习笔记】
    Node连接MySQL
    em 和 px相互转换
  • 原文地址:https://www.cnblogs.com/gongcb/p/2803480.html
Copyright © 2011-2022 走看看