Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set Bitmap as background of Text View - 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!

like image 664
superuser Avatar asked Dec 18 '13 09:12

superuser


People also ask

What process will you employ to apply bitmap to the background?

set bitmap to background of ImageView with imageView. setImageBitmap method.


1 Answers

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));
like image 84
nitesh goel Avatar answered Sep 28 '22 19:09

nitesh goel