Skip to content

Commit 12974b9

Browse files
committed
Fixed method
setRadian Method Make to change radian programmatically
1 parent cb0531e commit 12974b9

2 files changed

Lines changed: 12 additions & 5 deletions

File tree

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,3 +65,5 @@ fastlane/Preview.html
6565
fastlane/screenshots
6666
fastlane/test_output
6767
fastlane/readme.md
68+
69+
.DS_Store

roundlinearlayout/src/main/java/tk/dsjin/roundlinearlayout/RoundLinearLayout.kt

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,7 @@ class RoundLinearLayout: LinearLayout {
3939
}
4040
override fun onSizeChanged(w: Int, h: Int, oldw: Int, oldh: Int) {
4141
super.onSizeChanged(w, h, oldw, oldh)
42-
path.reset()
43-
val rect = RectF()
44-
rect.set(0f, 0f, w.toFloat(), h.toFloat())
45-
path.addRoundRect(rect, radian.toFloat(), radian.toFloat(), Path.Direction.CW)
46-
path.close()
42+
setNewPath(w, h)
4743
}
4844

4945
override fun draw(canvas: Canvas) {
@@ -55,6 +51,15 @@ class RoundLinearLayout: LinearLayout {
5551

5652
fun setRadius(radian : Int){
5753
this.radian = radian
54+
setNewPath(super.getWidth(), super.getHeight())
5855
invalidate()
5956
}
57+
58+
private fun setNewPath(w : Int , h : Int){
59+
path.reset()
60+
val rect = RectF()
61+
rect.set(0f, 0f, w.toFloat(), h.toFloat())
62+
path.addRoundRect(rect, radian.toFloat(), radian.toFloat(), Path.Direction.CW)
63+
path.close()
64+
}
6065
}

0 commit comments

Comments
 (0)