内部图像嵌入文本 [英] Embed text inside image

查看:144
本文介绍了内部图像嵌入文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要显示的图像内自定义文本(主要是个人信息)

I want to display a custom text (mainly person info) inside image

我如何能做到在android系统?例如,我有这样的图像(它不同于设备到设备)的已知大小和要与它里面的不同文本大小的特殊的地方,显示它(例如上文中的链接)。

How can I do it in android? For example I have a known size of this image (it differs from device to device) and want to display it with the different text size inside it in the special place (example is above in link).

推荐答案

有几个方法可以做到这一点。

There are a few ways to accomplish this.

我会做它的方式是使图像分成的 9补丁。要么不让它伸展,或标记舒展字符以外的地区。在这两种情况下,使用权和底部区域,以纪念在图形中你想要的文字去。

The way I would do it is to make the image into a 9-patch. Either don't allow it to stretch, or mark areas outside of the character to stretch. In either case, use the right and bottom regions to mark where in the image you want the text to go.

然后你只需设置9补丁为背景的的TextView ,你的文字将被放置在您在9补丁标记的区域。

Then you simply set the 9-patch as the background for a TextView, and your text will be placed in the region you marked in the 9-patch.

另一种方法是使用 RelativeLayout的的ImageView 的TextView ,那么就定位在你需要它的TextView的。不过,我觉得对付试图用这种方法很繁琐,而且容易出错完美定位的看法。一个9补丁也将让你与文本的几乎任何长度的使用此图片,而不用担心内容的区域外运行文本。

An alternative method would be to use a RelativeLayout with an ImageView and a TextView, then just position the TextView where you need it. However, I find dealing with trying to position views perfectly using this method to be tedious and error-prone. A 9-patch would also allow you to use this image with nearly any length of text without worrying about the text running outside the content region.

这篇关于内部图像嵌入文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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