具有剪切范围的自定义SHAPED布局 [英] Custom SHAPED Layout with clipping bounds
问题描述
是的,到目前为止,我找不到任何可以真正帮助我的东西...从StackOverflow
到libraries
以及其他内容...
Well yes, I couldn't find anything that could help me for real so far... from StackOverflow
to libraries
and other things...
我需要一个自定义形状的FrameLayout
,该形状将他的孩子修剪在其中.问题是我希望此shape
真正自定义,例如shirt / hat / etc..
I need a custom shaped FrameLayout
that is clipping his child inside of it. The problem is that I want this shape
to be really custom, for example shirt / hat / etc..
所以,我想以某种方式将FrameLayout
的孩子夹在衬衫内.我找到了与onDraw
方法有关的内容,但是没有找到获取vector
的pathData的方法. .
So, somehow I want to clip child of FrameLayout
inside the shirt let's say. I found something related to onDraw
method, but I didn't find a way of getting pathData of a vector
. . .
任何有关如何进行分类(如果可能)的明确想法都欢迎!
Any clear idea about how I could sort this up ( if possible ) is welcomed !
谢谢
推荐答案
您可以使用剪辑路径.您的代码可能类似于:
You can use clip path. Your code can look something like:
private void updatePath() {
path = new Path();
// Draw your special shape...
}
@Override
protected boolean drawChild(Canvas canvas, View child, long drawingTime) {
canvas.clipPath(path);
return super.drawChild(canvas, child, drawingTime);
}
@Override
protected void onDraw(Canvas canvas) {
canvas.clipPath(path);
super.onDraw(canvas);
}
这篇关于具有剪切范围的自定义SHAPED布局的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!