android将path拆分为多个path
16lz
2021-01-25
在android开发中,我们有时会采用如下api来生成一个Path对象:
Path path = new Path();path.addPath(firstPath);path.addPath(secondPath);
后期我们想将该path拆分为多个path,可以采用如下方法:
ArrayList<Path> list = new ArrayList<Path>();PathMeasure pm = new PathMeasure(path, true);float segment = 0;Path tempPath;do { tempPath = new Path(); tempPath.rewind(); pm.getSegment(segment, segment + pm.getLength(), tempPath, true); segment += pm.getLength(); tempPath.close(); list.add(tempPath);} while (pm.nextContour());
上述代码返回的list即为我们之前添加到path中的各个Path对象的集合。
更多相关文章
- 没有一行代码,「2020 新冠肺炎记忆」这个项目却登上了 GitHub 中
- android activity-alias 的作用
- android的Dialog使用
- day4.12总结_view Animation和Property Animation
- android中的保存数据方法
- Android(安卓)studio的安装、环境配置和使用方法
- Android(安卓)adb.exe程序启动不起来处理方法
- Android(安卓)Studio 自动代码提示设置
- android 混淆代码