从右到左的Andr​​oid画布上的drawText [英] Android canvas drawText from right to left

查看:425
本文介绍了从右到左的Andr​​oid画布上的drawText的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个应用程序HANDELS阿拉伯语太多,但我的阿拉伯语用户有一个问题,即的drawText翻转字..阿拉伯必须由右至左。如何使右画布的drawText向左?

I have an app that handels Arabic too, but my Arabic users have a problem that the drawText flip the word .. Arabic must be from right to left. How do I make the canvas drawText from right to left?

图中看到突出显示的文本是正确的文本的一个TextView和它的罚款。但是,在画布的drawText一个在一个圆是错误的。它必须是由右至左,如何让我的画布上的drawText从右到左?

See in the picture the highlighted text is the right text its a textView and it's fine. But the canvas DrawText the one in a circle is wrong. It must be from right to left, how do I make the canvas drawText from right to left?

推荐答案

在画布只是创建两边两点要绘制文本,然后创建它们之间的路径。使用这种方法,它会正常工作

On the canvas just create two points on sides where you want to draw text, and then create path between them. use this method it will work fine

Path path = new Path();
Paint paint = new Paint();
path.moveTo(p2.x, p2.y);
path.lineTo(p1.x, p1.y);
canvas.drawTextOnPath(String.valueOf(txt), path, (float) (c.getWidth() / (2.3)),  (float) (c.getHeight()/2 + paint.getTextSize()/1.5), paint);

这篇关于从右到左的Andr​​oid画布上的drawText的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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