具有剪切范围的自定义SHAPED布局 [英] Custom SHAPED Layout with clipping bounds

查看:78
本文介绍了具有剪切范围的自定义SHAPED布局的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是的,到目前为止,我找不到任何可以真正帮助我的东西...从StackOverflowlibraries以及其他内容...

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆