Is there any way to define the clip region of a ViewGroup in android (Honeycomb)? For example, I have a ListView with an image background that has rounded corners. As I scroll through the list, the children stick out past the corners of the background - I would prefer them to clip within the rounded corners.
左图是它当前正在做的事情,右图是我想要的事情。
我正在看ClipDrawable,但似乎这可能只能用于进度条?
另外,我正在尝试在小部件中执行此操作。所以我不能使用自定义视图并覆盖 onDraw 进行遮罩。
谢谢你!
确保layout
有圆角背景。
Kotlin
layout.outlineProvider = ViewOutlineProvider.BACKGROUND
layout.clipToOutline = true
Java
layout.setOutlineProvider(ViewOutlineProvider.BACKGROUND);
layout.setClipToOutline(true);
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)