如何在编辑字段中的文本上绘制位图?
我想在编辑字段中输入的文本上绘制位图图像。
我怎样才能做到这一点?
I would like to draw bitmap image over the text that I type in editfield.
How can I do that?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要对
EditField
进行子类化,然后重写paint
方法。在重写中,在执行任何操作之前调用super.paint
以便组件可以绘制文本,然后您可以使用 Paint 提供的Graphics
对象来绘制 < code>Bitmap 覆盖EditField
的内容 (Graphics.drawBitmap
)。You will need to subclass
EditField
and then override thepaint
method. In the override, callsuper.paint
before you do anything so that the component can draw the text, and then you can use theGraphics
object provided by paint to draw aBitmap
over the contents of theEditField
(Graphics.drawBitmap
).