This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bottomSheetBehavior.setBottomSheetCallback(object : BottomSheetBehavior.BottomSheetCallback() { | |
override fun onSlide(p0: View, p1: Float) { | |
val ra = radius - (radius * p1) | |
(p0 as CurvedLayout).setCorner(ra) | |
} | |
override fun onStateChanged(p0: View, p1: Int) { | |
} | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun setCorner(radius: Float) { | |
mCurveStartPoint.set(0, radius.toInt()) | |
mCurveEndPoint.set(mWidth, radius.toInt()) | |
//Apply our new points to our path like above | |
mPath.apply { | |
//... | |
invalidate() | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
override fun onSizeChanged(w: Int, h: Int, oldw: Int, oldh: Int) { | |
//... | |
mPath.apply { | |
//1.Step | |
moveTo( | |
mCurveStartPoint.x.toFloat(), | |
mCurveStartPoint.y.toFloat() | |
) | |
//2.Step |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
override fun onSizeChanged(w: Int, h: Int, oldw: Int, oldh: Int) { | |
super.onSizeChanged(w, h, oldw, oldh) | |
mCurveStartPoint.set(0, radius) | |
mCurveEndPoint.set(w, radius) | |
mControlPoint1.set( | |
mCurveStartPoint.x + radius, | |
mCurveStartPoint.y - radius) | |
mControlPoint2.set( |