Question:
I have got an Activity
used as a popup.
It's background is a shape with rounded corners.
But the items of it's content view don't fill out the shape. They are more likely inside of an invisible rectangle inside of the shape.
Can I somehow make them fill the shape and being cut when overlapping the corners?
Solution:
view.setClipToOutline(true); --> clips the view view.setOutlineProvider(ViewOutlineProvider.BACKGROUND); --> tells the view to be clipped by the background(shape)
Yes, it's possible to do this. It's called View Clipping
.
Here is an existing question about clipping: Android View Clipping
You have 2 options:
1- Implement a custom View
and override onDraw
so you can perform the clipping manually. See here: https://stackoverflow.com/a/28206555/6007104
2- Use View.outlineProvider
and View.clipToOutline
. This is the easier option, but only available on SDK 21+. See here: https://stackoverflow.com/a/54202660/6007104
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.