Drawable Resources
A drawable resource is a general concept for a graphic that can be drawn to the screen.
There are several different types of drawables:
- Bitmap File
- Nine-Patch File
- Layer List
- State List
- Level List
- Transition Drawable
- Inset Drawable
- Clip Drawable
- Shape Drawable
Layer List
A LayerDrawable
is a drawable object that manages an array of other drawables. Each drawable in the list is drawn in the order of the list—the last drawable in the list is drawn on top.
Each drawable is represented by an <item>
element inside a single <layer-list>
element.
<layer-list>
This must be the root element. Contains one or more `
命名空间:
xmlns:android="http://schemas.android.com/apk/res/android" |
<item>
Must be a child of a
example
|
|
State List
最常用的selector
Level List
Android 电量图标显示用到的技术
Transition Drawable
Inset Drawable
Clip Drawable
Scale Drawable
Shape Drawabel
android:shape=["rectangle" | "oval" | "line" | "ring"]
缺省值是rectangle
<stroke>
边框颜色
<solid>
填充颜色
<padding>
不知道什么效果
<gradient>
填充渐变颜色
<corners>
设置圆角
如何设置特定上下左右位置圆角 Every corner must (initially) be provided a corner radius greater than 1, or else no corners are rounded. If you want specific corners to not be rounded, a work-around is to use android:radius to set a default corner radius greater than 1, but then override each and every corner with the values you really want, providing zero (“0dp”) where you don’t want rounded corners.
|