如何在Android中绘制弯曲的文本 [英] How to draw curved text in Android

查看:66
本文介绍了如何在Android中绘制弯曲的文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试构建一个文本编辑应用程序,允许用户使用不同的字体、颜色、大小、旋转等来编辑文本.我正在研究一个应该弯曲文本的功能,但我已经不知道该怎么做.我发现这个 StackOverflow 帖子

解决方案

您可以在自定义视图中绘制圆形文本,使用画布函数 drawTextOnPath(String text,Path path, float hOffset, float vOffset,Paint paint),以及然后根据自己的需求构建路径.

I'm trying to build a text editing app that allows the user to edit text using different fonts, colors, sizes, rotations, etc. I'm working on a feature that is supposed to curve the text but I've got no clue how to do it. I found this StackOverflow post HERE and searching through the comments, I found this post HERE but for what I'm trying to achieve, that is how I want it to end up. What I want it to do is start as a normal line of text and then based on the value of a seekbar I want it to curve, until it reaches the MAX value at which point it's in a circle (as seen in the second link). If you can help me figure out how to do this I would really appreciate it. I figure it's going to use path.addArc or something like that but I'm not sure.

Thank you

PS I'll post the images below just in case you don't want to go look at the links

解决方案

You can draw your circle text in your custom view, use canvas function drawTextOnPath(String text,Path path, float hOffset, float vOffset,Paint paint), and then construct the path by yourself requirement.

这篇关于如何在Android中绘制弯曲的文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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