安卓查看剪辑 [英] Android View Clipping
问题描述
有没有什么办法来定义的ViewGroup的剪辑区域的机器人(蜂窝)?例如,我有一个形象的背景下,具有圆角一个ListView。当我滚动列表,孩子们伸出过去背景的角落 - 我想preFER他们中的圆角裁剪。
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.
左图是它目前正在做的,右边的是什么,我想。
The left image is what it is currently doing, and the right is what I'd like.
我在看ClipDrawable,但似乎这可能仅用于进度条?
I was looking at ClipDrawable, but it seems that this may only be used for progress bars?
另外,我也想这样做的一个小部件。所以我不能使用自定义的视图,并覆盖OnDraw的掩盖。
Also, I'm trying to do this in a widget. So I cannot use a custom view and override onDraw for masking.
感谢您!
推荐答案
通过创建自定义布局覆盖的OnDraw(帆布油画)
呼叫 canvas.cli preCT(0,0,mCanvasWidth,mCanvasHeight);
这将剪辑出去布局界各方意见。
this will clip all views that goes out of layout boundary.
不要忘记调用 setWillNotDraw(假)
的构造函数,所以你的OnDraw就会执行
And don't forget to call setWillNotDraw(false)
in constructor, so your onDraw will execute
这篇关于安卓查看剪辑的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!