Android: How to set ImageSwitcher image from bitmap? does setImageBitmap not exist?

I can not find setImageBitmap from ImageSwitcher. is there any way to set it using a bitmap?

UPDATES1 then I found this -> set image from file URI

But my case: I need to draw something in a bitmap before it is set to ImageSwitcher. So, is there no way to set it through a bitmap? if there is no way, I have to output the image file from the modified bitmap, and then use setImageURI. But this is a waste of memory.

UPDATES2 Alternative. Is there a way to dynamically store an image file from an SD card in R.drawable or R.raw to generate a resource identifier / identifier. Then use it for setImageResource or setImageDrawable?

+6
source share
2 answers

You can wrap your Bitmap in BitmapDrawable and use ImageSwitcher. setImageDrawable .

+11
source

you can convert the bitmap to drawable and assign drawable to image switcher as

Drawable drawable =new BitmapDrawable(bitmap); mSwitcher.setImageDrawable(drawable); 
+13
source

Source: https://habr.com/ru/post/897359/


All Articles