如何绘制Arrowline在android.graphics.Path与正确configerations [英] How to Draw Arrowline in android.graphics.Path with correct configerations
本文介绍了如何绘制Arrowline在android.graphics.Path与正确configerations的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我曾尝试:
我试图显示与以下code中的箭头线
I'm trying to display the arrow line with following code
Path mArrowPath=new Paint();;
mArrowPath.rewind();
mArrowPath.moveTo(0, mHeight / 2);
mArrowPath.lineTo(mWidth / 2, 0);
mArrowPath.lineTo(mWidth, mHeight / 2);
mArrowPath.lineTo(mWidth * 3 / 4, mHeight / 2);
mArrowPath.lineTo(mWidth * 3 / 4, mHeight);
mArrowPath.lineTo(mWidth / 4, mHeight);
mArrowPath.lineTo(mWidth / 4, mHeight / 2);
mArrowPath.lineTo(0, mHeight / 2);
Shape pathshap = new PathShape(mArrowP,maxWidth,maxHeight);
ShapeDrawable shapeD = new ShapeDrawable(pathshap);
shapeD.draw(canvas); //display it in onDraw(Canvas canvas)
我已经得到了以下结果。
I have got the following result
问题:
我不能画出所需预期的结果,我不明白/查找路径配置参数,显示下面的结果!
我没有增加在长度 宽度的箭头线的大小。
I'm not able draw the required expected result, I'm failed to understand/find path configuration parameters for displaying following result! I'm failed to increase the length, width size of the arrow line.
预期结果:
任何帮助将不胜感激!
any help will be grateful !
推荐答案
您可以使用canvas.rotate()方法来旋转箭头
you can use canvas.rotate() method to rotate arrow
或
Path mArrowPath=new Paint();;
mArrowPath.rewind();
mArrowPath.moveTo(mWidth , mHeight / 2);
mArrowPath.lineTo(mWidth / 2, mHeight );
mArrowPath.lineTo(mWidth / 2, mHeight* 3 / 4);
mArrowPath.lineTo(0, mHeight* 3 / 4);
mArrowPath.lineTo(0, mHeight/ 4);
mArrowPath.lineTo(mWidth / 2, mHeight/ 4);
mArrowPath.lineTo(mWidth / 2,0);
mArrowPath.lineTo(mWidth , mHeight / 2);
Shape pathshap = new PathShape(mArrowP,maxWidth,maxHeight);
ShapeDrawable shapeD = new ShapeDrawable(pathshap);
shapeD.draw(canvas);
这篇关于如何绘制Arrowline在android.graphics.Path与正确configerations的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文