From feb187d87f2b22df9ab6ab241ae8755006cf93be Mon Sep 17 00:00:00 2001 From: kunfei Date: Fri, 6 Mar 2020 13:46:50 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/io/legado/app/ui/widget/ArcView.kt | 29 +++++++++---------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/widget/ArcView.kt b/app/src/main/java/io/legado/app/ui/widget/ArcView.kt index a6e8eaa1f..b9834132c 100644 --- a/app/src/main/java/io/legado/app/ui/widget/ArcView.kt +++ b/app/src/main/java/io/legado/app/ui/widget/ArcView.kt @@ -14,20 +14,27 @@ class ArcView @JvmOverloads constructor( private var mWidth = 0 private var mHeight = 0 - /** - * 弧形高度 - */ + //弧形高度 private val mArcHeight: Int - /** - * 背景颜色 - */ + //背景颜色 private val mBgColor: Int private val mPaint: Paint = Paint() private val mDirectionTop: Boolean val rect = Rect() val path = Path() + init { + val typedArray = context.obtainStyledAttributes(attrs, R.styleable.ArcView) + mArcHeight = typedArray.getDimensionPixelSize(R.styleable.ArcView_arcHeight, 0) + mBgColor = typedArray.getColor( + R.styleable.ArcView_bgColor, + Color.parseColor("#303F9F") + ) + mDirectionTop = typedArray.getBoolean(R.styleable.ArcView_arcDirectionTop, false) + typedArray.recycle() + } + override fun onDraw(canvas: Canvas) { super.onDraw(canvas) mPaint.style = Paint.Style.FILL @@ -69,14 +76,4 @@ class ArcView @JvmOverloads constructor( setMeasuredDimension(mWidth, mHeight) } - init { - val typedArray = context.obtainStyledAttributes(attrs, R.styleable.ArcView) - mArcHeight = typedArray.getDimensionPixelSize(R.styleable.ArcView_arcHeight, 0) - mBgColor = typedArray.getColor( - R.styleable.ArcView_bgColor, - Color.parseColor("#303F9F") - ) - mDirectionTop = typedArray.getBoolean(R.styleable.ArcView_arcDirectionTop, false) - typedArray.recycle() - } } \ No newline at end of file