A drawable resource is a general concept fora graphic that can be
drawn tothe screen and which you can retrieve with APIs such as
getDrawable(int) or apply to another XML resource with attributes
such as android:drawable and android:icon. There are several
different types of drawables:
- 图片资源是可以画在屏幕上图形。你可以通过API
getDrawable(int)方法获取图片对象或者通过属性android:drawable、android:icon来使用他们。他们有不同的类型:
- Bitmap File: A bitmap graphic file (.png, .jpg, or.gif). Creates a
BitmapDrawable.
Bitmap 文件: 一个图形文件(可以是png、jpg、gif文件、xml),使用BitmapDrawable来获取
- Nine-Patch File: A PNG filewith stretchable regions to allow image
resizing based oncontent (.9.png). CreatesaNinePatchDrawable..9文件: png文件:可以定义伸缩改变图片大小的部位(后缀是.9.png),使用NinePatchDrawable获取
- Layer List A Drawable that manages an array of other Drawables. These
are drawn in array order, so theelementwiththe largest index is be
drawn ontop. CreatesaLayerDrawable.
图层: 由多个图片组合成一个图片。他们按顺序被画出,所以最后一个图片被画在最顶层,使用LayerDrawable获取
- State List An XML file that references different bitmap graphics for
different states (for example, to use a different image when a button
is pressed). Creates a StateListDrawable.
状态资源: 一个Xml,用来在不同的状态下显示不同的Bitmap对象。
- Level List An XML file that defines a drawable that manages anumberof alternate Drawables, each assigned a maximum numerical value.
Creates a LevelListDrawable.
- Transition Drawable An XML file that defines a drawable that can
cross-fade between two drawable resources. Creates
简介: A drawable resource is a general concept for a graphic that can be drawn to the screen and which you can retrieve with APIs such as getDrawable(int) or apply to another XML resource with attr