What is the difference between Bitmap and Drawable in Android?

A Bitmap is a representation of a bitmap image (something like java.awt.Image). A Drawable is an abstraction of "something that can be drawn". It could be a Bitmap (wrapped up as a BitmapDrawable), but it could also be a solid color, a collection of other Drawable objects, or any number of other structures.

Most of the Android UI framework likes to work with Drawable objects, not Bitmap objects. A View can accept any Drawable as a background. An ImageView can display a foreground Drawable. Images stored as resources are loaded as Drawable objects.

Bitmap is not an image. Bitmap is a map of bit (note name: Bit-map). And this map represents pixels on which you can draw something. It may be your own custom bitmap (not image), for example square:

Bitmap bitmap = Bitmap.createBitmap(100, 100, Bitmap.Config.ARGB_8888);

or you can create Bitmap object from image:

Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.your_image);    

A Bitmap is a pixels holder. And Canvas is used to draw something on your bitmap (on Bitmap pixels).

Everything about Drawable is well described above.


Some people write that you draw on Canvas. You don't draw on Canvas. You draw on Bitmap pixels with Canvas helper method.

Bitmap bitmap = Bitmap.createBitmap(100, 100, Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(bitmap);
canvas.drawColor(Color.RED) // now all bitmap pixels became red