DashedLine.java 文件源码

java
阅读 38 收藏 0 点赞 0 评论 0

项目:hypertrack-live-android 作者:
public DashedLine(Context context, AttributeSet attrs) {
    super(context, attrs);
    int dashGap, dashLength, dashThickness;
    int color;

    TypedArray a = context.getTheme().obtainStyledAttributes(attrs, R.styleable.DashedLine, 0, 0);

    try {
        dashGap = a.getDimensionPixelSize(R.styleable.DashedLine_dashGap, 5);
        dashLength = a.getDimensionPixelSize(R.styleable.DashedLine_dashLength, 5);
        dashThickness = a.getDimensionPixelSize(R.styleable.DashedLine_dashThickness, 3);
        color = a.getColor(R.styleable.DashedLine_color, 0xff000000);
        orientation = a.getInt(R.styleable.DashedLine_orientation, ORIENTATION_HORIZONTAL);
    } finally {
        a.recycle();
    }

    mPaint = new Paint();
    mPaint.setAntiAlias(true);
    mPaint.setColor(color);
    mPaint.setStyle(Paint.Style.STROKE);
    mPaint.setStrokeWidth(dashThickness);
    mPaint.setPathEffect(new DashPathEffect(new float[]{dashLength, dashGap,}, 0));
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号