public CountDownProgress(Context context, AttributeSet attrs, int defStyleAttr) {
? ? ? ? super(context, attrs, defStyleAttr);
? ? ? ? //獲取自定義屬性
? ? ? ? TypedArray typedArray = getContext().obtainStyledAttributes(attrs, R.styleable.CountDownProgress);
? ? ? ? int indexCount = typedArray.getIndexCount();
? ? ? ? for(int i=0;i<indexCount;i++){
? ? ? ? ? ? int attr = typedArray.getIndex(i);
? ? ? ? ? ? switch (attr){
? ? ? ? ? ? ? ? case R.styleable.CountDownProgress_default_circle_solide_color:
? ? ? ? ? ? ? ? ? ? defaultCircleSolideColor = typedArray.getColor(attr, defaultCircleSolideColor);
? ? ? ? ? ? ? ? ? ? break;
? ? ? ? ? ? ? ? case R.styleable.CountDownProgress_default_circle_stroke_color:
? ? ? ? ? ? ? ? ? ? defaultCircleStrokeColor = typedArray.getColor(attr, defaultCircleStrokeColor);
? ? ? ? ? ? ? ? ? ? break;
? ? ? ? ? ? ? ? case R.styleable.CountDownProgress_default_circle_stroke_width:
? ? ? ? ? ? ? ? ? ? defaultCircleStrokeWidth = (int) typedArray.getDimension(attr, defaultCircleStrokeWidth);
? ? ? ? ? ? ? ? ? ? break;
? ? ? ? ? ? ? ? case R.styleable.CountDownProgress_default_circle_radius:
? ? ? ? ? ? ? ? ? ? defaultCircleRadius = (int) typedArray.getDimension(attr, defaultCircleRadius);
? ? ? ? ? ? ? ? ? ? break;
? ? ? ? ? ? ? ? case R.styleable.CountDownProgress_progress_color:
? ? ? ? ? ? ? ? ? ? progressColor = typedArray.getColor(attr, progressColor);
? ? ? ? ? ? ? ? ? ? break;
? ? ? ? ? ? ? ? case R.styleable.CountDownProgress_progress_width:
? ? ? ? ? ? ? ? ? ? progressWidth = (int) typedArray.getDimension(attr, progressWidth);
? ? ? ? ? ? ? ? ? ? break;
? ? ? ? ? ? ? ? case R.styleable.CountDownProgress_small_circle_solide_color:
? ? ? ? ? ? ? ? ? ? smallCircleSolideColor = typedArray.getColor(attr, smallCircleSolideColor);
? ? ? ? ? ? ? ? ? ? break;
? ? ? ? ? ? ? ? case R.styleable.CountDownProgress_small_circle_stroke_color:
? ? ? ? ? ? ? ? ? ? smallCircleStrokeColor = typedArray.getColor(attr, smallCircleStrokeColor);
? ? ? ? ? ? ? ? ? ? break;
? ? ? ? ? ? ? ? case R.styleable.CountDownProgress_small_circle_stroke_width:
? ? ? ? ? ? ? ? ? ? smallCircleStrokeWidth = (int) typedArray.getDimension(attr, smallCircleStrokeWidth);
? ? ? ? ? ? ? ? ? ? break;
? ? ? ? ? ? ? ? case R.styleable.CountDownProgress_small_circle_radius:
? ? ? ? ? ? ? ? ? ? smallCircleRadius = (int) typedArray.getDimension(attr, smallCircleRadius);
? ? ? ? ? ? ? ? ? ? break;
? ? ? ? ? ? ? ? case R.styleable.CountDownProgress_text_color:
? ? ? ? ? ? ? ? ? ? textColor = typedArray.getColor(attr, textColor);
? ? ? ? ? ? ? ? ? ? break;
? ? ? ? ? ? ? ? case R.styleable.CountDownProgress_text_size:
? ? ? ? ? ? ? ? ? ? textSize = (int) typedArray.getDimension(attr, textSize);
? ? ? ? ? ? ? ? ? ? break;
? ? ? ? ? ? }
? ? ? ? }
? ? ? ? //回收typedArray對(duì)象
? ? ? ? typedArray.recycle();
? ? ? ? //設(shè)置畫筆
? ? ? ? setPaint();
? ? }