@@ -28,7 +28,6 @@ class ArcView : View {
2828 private var mPaint = Paint ()
2929 private var mContext: Context ? = null
3030
31- private var mRect = Rect ()
3231 private var mPath = Path ()
3332
3433 constructor (context: Context ) : this (context, null )
@@ -44,29 +43,30 @@ class ArcView : View {
4443 typedArray.recycle()
4544
4645 mContext = context
47- mPaint.style = Paint .Style .FILL
46+ mPaint.style = Paint .Style .FILL_AND_STROKE
4847 mPaint.color = mBgColor
4948 mPaint.isAntiAlias = true
49+ mPaint.strokeWidth = 1f
5050 }
5151
5252 override fun onSizeChanged (w : Int , h : Int , oldw : Int , oldh : Int ) {
5353 super .onSizeChanged(w, h, oldw, oldh)
5454 mWidth = w
5555 mHeight = h
56- mRect.set(0 , 0 , mWidth, mHeight - mArcHeight)
5756 resetPath()
5857 }
5958
6059 private fun resetPath () {
6160 mPath.reset()
62- mPath.moveTo(0f , (mHeight - mArcHeight).toFloat())
61+ mPath.moveTo(0f , 0f )
62+ mPath.lineTo(0f , (mHeight - mArcHeight).toFloat())
6363 mPath.quadTo((mWidth / 2 ).toFloat(), (mHeight + mArcHeight).toFloat(), mWidth.toFloat(), (mHeight - mArcHeight).toFloat())
64+ mPath.lineTo(mWidth.toFloat(), 0f )
6465 mPath.close()
6566 }
6667
6768 override fun onDraw (canvas : Canvas ? ) {
6869 super .onDraw(canvas)
69- canvas?.drawRect(mRect, mPaint)
7070 canvas?.drawPath(mPath, mPaint)
7171 }
7272
@@ -81,7 +81,6 @@ class ArcView : View {
8181 fun setArcViewHeight (height : Int ) {
8282 if (height == mHeight) return
8383 mHeight = height
84- mRect.set(0 , 0 , mWidth, mHeight - mArcHeight)
8584 resetPath()
8685 invalidate()
8786 }
0 commit comments