如何将文本中绘制? [英] How to put text in a drawable?

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

问题描述

我想即时创建一个可绘制作为背景,自定义的LinearLayout使用。它需要有哈希标记等(没有什么大不了的),但也有数字标识什么的散列标志是(像一把尺子)。我知道我可以只创建文本元素,并把它们的LinearLayout内,只是有哈希标记的绘制,但我希望能有他们的绘制内为好,所以我没有做测量计算两次。

I'm trying to create a drawable on the fly to use as a background for a custom linearlayout. It needs to have hash marks and such (no big deal), but also have numbers labeling what the hash marks are (like a ruler). I know I can just create text elements and put them inside the linearlayout and just have the hash marks in the drawable, but I'm hoping to have them inside the drawable as well, so I don't have to do measurement calculations twice.

推荐答案

我读过的书专业机器人2应用程序开发(由雷托•梅耶尔)。除其他外,它包含在您创建一个简单的指南针的应用程序,你画的例子项目文本,标记等。

I've read the book "Professional Android 2 Application Development" (by Reto Meier). Amongst others, it contains an example project where you create a simple compass application where you "draw" text, markers etc.

简要说明的是,你创建一个类,扩展了 android.view.View 类,并覆盖的OnDraw(画布)方法。

The brief explanation is that you create a class that extends the android.view.View class and overrides the onDraw(Canvas) method.

所有的源$ C ​​$ C组成的书是可以从这里下载:<一href="http://www.wrox.com/WileyCDA/WroxTitle/Professional-Android-2-Application-Development.productCd-0470565527,descCd-DOWNLOAD.html">http://www.wrox.com/WileyCDA/WroxTitle/Professional-Android-2-Application-Development.productCd-0470565527,descCd-DOWNLOAD.html.如果你下载的code和期待命名为第4章北斗的项目中,我相信你会发现你在找什么:)

All the source code form the book is available for download here: http://www.wrox.com/WileyCDA/WroxTitle/Professional-Android-2-Application-Development.productCd-0470565527,descCd-DOWNLOAD.html. If you download the code and look inside the project named "Chapter 4 Compass", I believe you would find what you're looking for :)

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

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