如何在Android中的画布上使用Path(android.graphics.Path)? [英] How to use Path (android.graphics.Path) with canvas in android?

查看:101
本文介绍了如何在Android中的画布上使用Path(android.graphics.Path)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在研究实现循环菜单"之类的Catch应用程序的自定义视图.花了很多时间后,我取得了一些进步,完成了带有多色颜色的外半圆.现在,在阅读Catch应用程序开发人员提供给用户的查询答案时,我遇到了Path类. Google Android开发人员页面没有提供足够的材料来理解和熟悉Path.所以,请 ?有人吗?

I am working on a Custom View that implements Catch application like Circular Menu. After spending a lot of time, I have made a bit of progress, completed outer semi-circle with multile colors. Now, reading an answer provided by developer of Catch application to an user for his query, I came across the class Path. Google Android Developer page does not provides enough material to be understood and to be familiar with Path. so, Please ? Anyone ?

谢谢.

推荐答案

您可以使用它在画布上绘制线条.路径基本上是线的集合.您可以使用它来创建非标准形状.例如.有很多功能可以创建一些默认形状:

You can use it to draw lines on a canvas. A path is basically a collection of lines. You can use it to create shapes that are not standard. E.g. there a lots of functions to create some default shapes:

canvas.drawRect();
canvas.drawArc(RectF oval, float startAngle, float sweepAngle, boolean useCenter, Paint paint);
canvas.drawCircle(float cx, float cy, float radius, Paint paint);
canvas.drawLine(float startX, float startY, float stopX, float stopY, Paint paint);
canvas.drawOval(RectF oval, Paint paint);
canvas.drawRect(float left, float top, float right, float bottom, Paint paint);

但是,如果您需要自定义内容,则可以创建路径,并调用

But if you want something custom, you can create a path, and by calling

// Set the beginning of the next contour to the point (x,y).
void     moveTo(float x, float y)

// Add a line from the last point to the specified point (x,y).
void     lineTo(float x, float y)

您可以控制绘制路径的铅笔. 这是一个不错的教程

You have control of the pencil that draws the lines of your path. Here's a nice tutorial

这篇关于如何在Android中的画布上使用Path(android.graphics.Path)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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