Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the difference between Bitmap, BitmapDrawable and Drawable?

I saw this answer: What is the difference between Bitmap and Drawable in Android?

Can anyone give a practical explanation? When to use? Advantage disadvantage?

like image 219
Kim Montano Avatar asked Nov 30 '25 06:11

Kim Montano


1 Answers

Bitmap is just an image as-is. Ideally it would be used to draw pixels on the screen with a Canvas, using a SurfaceView or something like that.

Drawable is a class that describes something that can be drawn on the screen.

BitmapDrawable is a subclass from Drawable. This means that it's a Drawable that wants to draw an image.

Usually android views work with Drawable objects, so any subclass of Drawable is acceptable, this means that if you want to use a Bitmap (raw pixels) on a View you need to create a BitmapDrawable and pass it to it.

like image 199
TomTsagk Avatar answered Dec 02 '25 20:12

TomTsagk