![](https://csdnimg.cn/release/download_crawler_static/11647283/bg4.jpg)
}
private void init(Context context, AttributeSet attrs, int defStyleAttr) {
defaultNormalLineColor = Color.parseColor("#545454");
defaultPassLineColor = Color.WHITE;
defaultTextColor = Color.WHITE;
defaultLineStikeWidth = dp2px(context, 1);
defaultTextSize = sp2px(context, 80);
defaultText2DotMargin = dp2px(context, 15);
defalutMargin = dp2px(context, 100);
defaultLine2TopMargin = dp2px(context, 30);
defaultText2BottomMargin = dp2px(context, 20);
normal_pic = BitmapFactory.decodeResource(getResources(), R.drawable.ic_normal);
target_pic = BitmapFactory.decodeResource(getResources(), R.drawable.ic_target);
passed_pic = BitmapFactory.decodeResource(getResources(), R.drawable.ic_passed);
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.StepView,
defStyleAttr, 0);
dotCount = a.getInt(R.styleable.StepView_count, defaultDotCount);
if (dotCount < 2) {
throw new IllegalArgumentException("Steps can't be less than 2");
}
stepNum = a.getInt(R.styleable.StepView_step, defaultStepNum);
lineLength = a.getInt(R.styleable.StepView_line_length, defaultLineLength);
maxDotCount = a.getInt(R.styleable.StepView_max_dot_count, defaultMaxDotCount);
if (maxDotCount < dotCount) {//
当最多点小于设置点数量时,设置线条长度可变
lineLength = defaultLineLength;
}