Note: You can use a <bitmap> element as a child of an<item> element. Forexample, when creating astate list orlayer list,you can exclude theandroid:drawableattribute from an<item> element and nest a<bitmap> inside it that defines the drawable item.
文件位置:
res/drawable/filename.xml filename作为资源的ID
编译资源类型
指向BitmapDrawable类型的指针
资源引用
In Java:
R.drawable.filename In XML:
@[package:]drawable/filename
Put the object at the top of its container, not changing its size.
bottom
Put the object at the bottom of its container, not changing its size.
left
Put the object at the left edge of its container, not changing its size.
right
Put the object at the right edge of its container, not changing its size.
center_vertical
Place object in the vertical center of its container, not changing its size.
fill_vertical
Grow the vertical size of the object if needed so it completely fills its container.
center_horizontal
Place object in the horizontal center of its container, not changing its size.
fill_horizontal
Grow the horizontal size of the object if needed so it completely fills its container.
center
Place the object in the center of its container in both the vertical and horizontal axis, notchanging its size.
fill
Grow the horizontal and vertical size of the object if needed so it completely fills itscontainer. This is the default.
clip_vertical
Additional option that can be set to have the top and/or bottom edges of the child clipped toits container's bounds. The clip is based on the vertical gravity: a top gravity clips thebottom edge, a bottom gravity clips the top edge, and neither clips both edges.
clip_horizontal
Additional option that can be set to have the left and/or right edges of the child clipped toits container's bounds. The clip is based on the horizontal gravity: a left gravity clipsthe right edge, a right gravity clips the left edge, and neither clips both edges.
android:tileMode
类型:Keyword。
定义了tile模式。当tile模式被启用,位图是重复的,并且gravity属性将被忽略。
必须是下列之一常量值:
Value
Description
disabled
Do not tile the bitmap. This is the default value.
clamp
Replicates the edge color if the shader draws outside of its original bounds
repeat
Repeats the shader's image horizontally and vertically.
mirror
Repeats the shader's image horizontally and vertically, alternating mirror images so thatadjacent images always seam.