Created
October 16, 2025 06:09
-
-
Save imandaliya/53f5a56cda94fdbd0f451556df401902 to your computer and use it in GitHub Desktop.
Clip View By Rect
This file contains hidden or 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 BottomAppBar.clipTopCorners() { | |
| elevation = resources.getDimensionPixelSize(R.dimen.dp2).toFloat() | |
| outlineProvider = object : ViewOutlineProvider() { | |
| override fun getOutline(view: View, outline: Outline) { | |
| outline.offset(0, resources.getDimensionPixelSize(R.dimen.dp24)) | |
| outline.setRoundRect( | |
| 0, | |
| 0, | |
| view.width, | |
| view.height + resources.getDimensionPixelSize(R.dimen.dp24), | |
| resources.getDimensionPixelSize(R.dimen.dp24).toFloat() | |
| ) | |
| } | |
| } | |
| setClipToOutline(true) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment