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;
        }
        
    }
  • 相关阅读:
    垃圾邮件处理
    主成分分析
    逻辑回归实践
    特征选择
    逻辑回归
    15 手写数字识别-小数据集
    14 深度学习-卷积
    13-垃圾邮件分类2
    12.朴素贝叶斯-垃圾邮件分类
    11.分类与监督学习,朴素贝叶斯分类算法
  • 原文地址:https://www.cnblogs.com/gongcb/p/2803480.html
Copyright © 2011-2022 走看看