Set Bitmap as background of Text View - Android

2019-01-28 02:14发布

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!

1条回答
爷的心禁止访问
2楼-- · 2019-01-28 02:24

According to the API docs, setBackgroundResource expects an int.

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));
查看更多
登录 后发表回答