如何设置数字作为TextView的图像? [英] How to set numbers as images on TextView?

查看:93
本文介绍了如何设置数字作为TextView的图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我提出的显示器,其显示购买的总和。这是一个与背景图像一个TextView。我有一个设计的数字了。如何设置这些数字图像,都TextView的还是我必须创造一些布局而不是简单的TextView?如果我需要创建的布局,您可以添加一些code样品,我该怎么办呢?

I made a display, that will show the sum of purchase. It's a TextView with background image. I have a designed digits too. How can I set those digit images to that TextView or do I have to create some layout instead of simple TextView? If I need to create layout, can you add some code sample, how can I do it?

这是我想要达到什么样的一个例子。

Here's an example what I want to achieve.

问候,
evilone

Regards, evilone

推荐答案

据我所知,你的两个选择是创建你自己的真/ OpenTypeFont(在XML中最有可能的文本颜色设置为黄色)或至code你自己定制的ViewGroup,将一个字符串并将每个字符转换为相应的图像。

As far as I know, your two options would be to create your own True/OpenTypeFont (setting the color of the text to yellow in xml most likely) or to code your own custom ViewGroup which will take a String and convert each character to the appropriate image.

如果你能够构建自己的字体,你可以添加字体文件夹资产项目文件夹内,并把您的字体在里面。然后,它可以装载这样的:

If you're able to construct your own font, you can add a font folder inside your assets project folder, and put your font in it. It can then be loaded like this:

Typeface tf = Typeface.createFromAsset(myContext.getAssets(), "fonts/MyFont.ttf");
myTextView.setTypeface(tf);

本网站上有免费字体,甚至用于商业用途,请 http://www.fontsquirrel.com 和我搜索对领导并发现了一个名为字体的radioland看起来很不错,虽然数字是一个角度。如果你使用该网站,我发现这是很好验证的字体确实是免费的与它使用的包括许可证或软件,可以打开字体并查看它的头。

This site has free fonts even for commercial use, http://www.fontsquirrel.com and I searched for led and found a font called radioland that looks good, though the numbers are at an angle. If you do use that site, I've found it's good to verify the font is indeed free to use with it's included license or a software and can open the font and view it's headers.

这篇关于如何设置数字作为TextView的图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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