文本视图中的镜像文本?
我正在尝试做一个简单地将一堆文本输出到android屏幕的应用程序,问题是它必须被镜像(将被视为“hud”)。
令人惊讶的是,在 android 4.0 中,您可以通过简单地使用 textview.setScaleX(-1) 来使用 textview 来完成此操作...在 4.0 之前我找不到太多。 textview.setTextScaleX(-1) 不起作用(实际上它有点起作用,但只有一个字符出现,尽管它是镜像的)。 4.0 方法也适用于我的手机(nexus 运行 cm9)。
我偶然发现了一些建议,例如使用 AndroidCharacter.Mirror() 没有成功,我似乎只剩下 3 个选项:
1)编写自定义(镜像)字体 2)学习如何重写onDraw(按照Android TextView镜像(hud)?) 3)将其全部绘制到画布上。
第一个是合理的,我可能可以做到,但它限制了我只能使用一种语言(或很多工作)。第二个+第三个我很迷失,尽管我很确定我可以从我找到的几个例子中找出答案(例如:在画布上绘制镜像文本)。
在我尝试 2 或 3 之前,还有其他我可能没有考虑过的选择吗?
Im trying to do an application that simply outputs a bunch of text to the android screen, the problem is is that it has to be mirrored (Will be viewed as a "hud").
Surprisingly, in android 4.0, you can do this with a textview by simply going textview.setScaleX(-1)... prior to 4.0 I cant find much. textview.setTextScaleX(-1) doesnt work (actually it kinda works, but only one char comes up, though it is mirrored). The 4.0 approach also works on my phone (nexus s running cm9).
I've stumbled across a few suggestions, such as using AndroidCharacter.Mirror() with no success and it seems im left with 3 options:
1) Write a custom (mirrored) font
2) learn how to override onDraw (as per Android TextView mirroring (hud)?)
3) paint it all onto a canvas.
The first is plausible and i could probably do it, but it limits me to a single language (or a lot of work). The second + third Im quite lost with though Im pretty sure I can figure it out from a few examples i've found (this for example: Drawing mirror text on canvas).
Before I do attempt 2 or 3, is there any other options i've perhaps not considered?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我很确定 4.0 之前的 TextView 是不可能的。
镜像的自定义 TextView 并不难:
并用作:
Im pretty sure it is not possible with the pre-4.0 TextView.
A mirrored custom TextView is not that hard:
And use as: