Skip to content

Instantly share code, notes, and snippets.

@imandaliya
Created October 16, 2025 06:09
Show Gist options
  • Select an option

  • Save imandaliya/53f5a56cda94fdbd0f451556df401902 to your computer and use it in GitHub Desktop.

Select an option

Save imandaliya/53f5a56cda94fdbd0f451556df401902 to your computer and use it in GitHub Desktop.
Clip View By Rect
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