将位图设置为文本视图的背景 - Android

sup*_*ser 5 java android background bitmap textview

我在运行时在内存中有一个位图.我想将文本视图的背景设置为此位图.我无法找到任何标准程序(不是一个hacky程序).如果有人在这方面工作过,请帮忙!

nit*_*oel 21

根据API文档,setBackgroundResource需要一个int.

如果你肯定需要一个位图,你可以改用setBackgroundDrawable并将你的位图包装在BitmapDrawable中.例

textureView.setBackground(new BitmapDrawable(getResources(), bitmap));
Run Code Online (Sandbox Code Playgroud)