1. Bitmap 与 Drawable区别
首先看看Drawable类的注释
> A Drawable is a general abstraction for “something that can be drawn.”
> Most often you will deal with Drawable as the type of resource retrieved for
> drawing things to the screen; the Drawable class provides a generic API for
> dealing with an underlying visual resource that may take a variety of forms.
> Unlike a {@link android.view.View}, a Drawable does not have any facility to
> receive events or otherwise interact with the user.
Drawable是一个抽象类,代表的是“可绘制的东西”的一般抽象。通常你会将Drawable作为绘制事物到屏幕上的资源类型来处理,它提供了一个通用API来处理可能采用多种形式的底层视觉资源。与View不同的是,Drawable没有任何接收事件或以其他方式与用户交互的功能。平常我们使用的时候都是res目录下创建相应的drawable资源,比如button的背景图片,背景颜色,以及button不同的状态的动画效果等。
然后接着看下面一段注释
Though usually not visible to the application, Drawables may take a variety of forms:
> Bitmap: the simplest Drawable, a PNG or JPEG image.
> Nine Patch: an extension to the PNG format allows it to specify information about how to stretch it and place things inside of it.
> Vector: a drawable defined in an XML file as a set of points, lines, and curves along with its associated color information. This type of drawable can be scaled without loss of display quality.
> Shape: contains simple drawing commands instead of a raw bitmap, allowing it to resize better in some cases.
> Layers: a compound drawable, which draws multiple underlying drawables on top of each other.