将位图作为文本视图背景 - Android电子 [英] Set Bitmap as background of Text View - Android

查看:219
本文介绍了将位图作为文本视图背景 - Android电子的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有在运行时在存储器中的位图。我想设置一个文本视图来此位图的背景。我无法找到任何标准程序(而不是哈克之一)。
如果有人在这方面的工作,请大家帮忙!

I have a bitmap in memory at run-time. I want to set the background of a text view to this bitmap. I am not able to find any standard procedure for that (not a hacky one). If anybody has worked in this area, please help!

推荐答案

根据API文档,setBackgroundResource需要int。

According to the API docs, setBackgroundResource expects an int.

如果你肯定需要一个位图,您可以使用setBackgroundDrawable代替,敷位图在BitmapDrawable。
例如:

If you definitely need a bitmap, you can use setBackgroundDrawable instead and wrap your bitmap in a BitmapDrawable. example

textureView.setBackground(new BitmapDrawable(getResources(), bitmap));

这篇关于将位图作为文本视图背景 - Android电子的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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