Kim Montano
Kim Montano

Reputation: 2285

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?

Upvotes: 3

Views: 1708

Answers (1)

Tom Tsagkatos
Tom Tsagkatos

Reputation: 1494

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.

Upvotes: 4

Related Questions