public abstract class Drawable
extends Object
java.lang.Object | |
↳ | android.graphics.drawable.Drawable |
<com.myapp.MyCustomDrawable xmlns:android="http://schemas.android.com/apk/res/android"
android:color="#ffff0000" />
用drawable作为XML元素名并且从类的属性指定完整路径名。这个方法可以用在public 高层级类和public static 内部类。
<drawable xmlns:android="http://schemas.android.com/apk/res/android"
class="com.myapp.MyTopLevelClass$InnerCustomDrawable"
android:color="#ffff0000" />
总结
Nested classes(嵌套的类) | |
---|---|
接口 | Drawable.Callback 如果想要创建一个动画继承 Drawable 的drawable,就实现这个接口 |
类 | Drawable.ConstantState 这个抽象类被Drawables用来存储Drawables之间的共享状态和数据 |
Public constructors (公共构造函数) | |
---|---|
Drawable() |
Public methods | |
---|---|
void | applyTheme(Resources.Theme t) Applies the specified theme to this Drawable and its children. 应用指定的theme(主题)在Drawable和它的孩子 |
boolean | canApplyTheme() |
void | clearColorFilter() Removes the color filter for this drawable. 从drawable中移除颜色过滤器 |
final Rect | copyBounds() Return a copy of the drawable's bounds in a new Rect. 在新的矩形(Rect)返回一个drawable的约束副本 |
final void | copyBounds(Rect bounds) Return a copy of the drawable's bounds in the specified Rect (allocated by the caller). 在指定的矩形(Rect)返回一个drawable的约束副本 |
static Drawable | createFromPath(String pathName) Create a drawable from file path name. 从路径名(pathName)创建一个drawable |
static Drawable | createFromResourceStream(Resources res, TypedValue value, InputStream is,String srcName, BitmapFactory.Options opts) This method was deprecated in API level P. Prefer the version without an Options object. 这个方法在API P 中已经废弃了,请使用下面的方法 |
static Drawable | createFromResourceStream(Resources res, TypedValue value, InputStream is,String srcName) Create a drawable from an inputstream, using the given resources and value to determine density information. 从输入流创建一个drawable,使用给定的资源和值去决定密度信息。 |
static Drawable | createFromStream(InputStream is, String srcName) Create a drawable from an inputstream 从输入流创建一个drawable |
static Drawable | createFromXml(Resources r, XmlPullParser parser) Create a drawable from an XML document. 从一个XML文件中创建一个drawable |
static Drawable | createFromXml(Resources r, XmlPullParser parser, Resources.Theme theme) Create a drawable from an XML document using an optional 从一个XML文档用Resources.Theme创建一个drawable |
static Drawable | createFromXmlInner(Resources r, XmlPullParser parser, AttributeSet attrs,Resources.Theme theme) Create a drawable from inside an XML document using an optional 从一个XML文档使用一个可选的Resources.Theme创建一个drawable |
static Drawable | createFromXmlInner(Resources r, XmlPullParser parser, AttributeSet attrs) Create from inside an XML document. 从一个XML文档内创建 |
abstract void | draw(Canvas canvas) Draw in its bounds (set via setBounds) respecting optional effects such as alpha (set via setAlpha) and color filter (set via setColorFilter). 在它的约束内绘制,并遵从可选的效果,例如透明度alpha 和颜色过滤器 |
int | getAlpha() Gets the current alpha value for the drawable. 获取当前透明度的值 |
final Rect | getBounds() Return the drawable's bounds Rect. 返回drawable的约束矩形 |
Drawable.Callback | getCallback() Return the current 返回当前这个Drawable实现的Drawable.Callback |
int | getChangingConfigurations() Return a mask of the configuration parameters for which this drawable may change, requiring that it be re-created. 返回drawable可能会改变的配置参数,这需要drawable重建 |
ColorFilter | getColorFilter() Returns the current color filter, or 返回当前的颜色过滤器,返回null如果没设置的话 |
Drawable.ConstantState | getConstantState() Return a 返回存有这个Drawable的共享状态的 |
Drawable | getCurrent() |
Rect | getDirtyBounds() Return the drawable's dirty bounds Rect. 返回drawable的脏约束矩形 |
void | getHotspotBounds(Rect outRect) Populates 使用热点约束填充外矩形 |
int | getIntrinsicHeight() Returns the drawable's intrinsic height. 返回drawable的本身高度 |
int | getIntrinsicWidth() Returns the drawable's intrinsic width. 返回drawable的本身宽度 |
int | getLayoutDirection() Returns the resolved layout direction for this Drawable. 返回Drawable的布局方向 |
final int | getLevel() Retrieve the current level. 查询当前的level |
int | getMinimumHeight() Returns the minimum height suggested by this Drawable. 返回Drawable的建议最小高度 |
int | getMinimumWidth() Returns the minimum width suggested by this Drawable. 返回Drawable的建议最小宽度 |
abstract int | getOpacity() Return the opacity/transparency of this Drawable. 返回Drawable的不透明度或者透明度 |
void | getOutline(Outline outline) Called to get the drawable to populate the Outline that defines its drawing area. 调用此方法去获取drawable去填充定义在绘画区域的轮廓 |
boolean | getPadding(Rect padding) Return in padding the insets suggested by this Drawable for placing content inside the drawable's bounds. 返回内容与约束边框的内边距 |
int[] | getState() Describes the current state, as a union of primitve states, such as 描述当前状态,作为一个联合的基本状态,例如 |
Region | getTransparentRegion() Returns a Region representing the part of the Drawable that is completely transparent. 返回完全透明的范围 |
void | inflate(Resources r, XmlPullParser parser, AttributeSet attrs, Resources.Theme theme) Inflate this Drawable from an XML resource optionally styled by a theme. 从某个主题样式的XML资源填充这个drawable |
void | inflate(Resources r, XmlPullParser parser, AttributeSet attrs) Inflate this Drawable from an XML resource. 从XML 资源填充Drawable |
void | invalidateSelf() Use the current 使用当前 |
boolean | isAutoMirrored() Tells if this Drawable will be automatically mirrored when its layout direction is RTL right-to-left. 是否自动生成镜像 |
boolean | isFilterBitmap() |
boolean | isStateful() Indicates whether this drawable will change its appearance based on state. 标识是否根据状态来改变它的显示 |
final boolean | isVisible() |
void | jumpToCurrentState() If this Drawable does transition animations between states, ask that it immediately jump to the current state and skip any active animations. 如果这个Drawable从状态之间执行转换动画,询问他立即调到当前状态并且跳过所有的动画。 |
Drawable | mutate() Make this drawable mutable. 让这个Drawable易变的。 |
boolean | onLayoutDirectionChanged(int layoutDirection) Called when the drawable's resolved layout direction changes. 在drawable的布局方向改变时调用。 |
static int | resolveOpacity(int op1, int op2) Return the appropriate opacity value for two source opacities. 在两种不透明源中返回恰当的不透明度值 |
void | scheduleSelf(Runnable what, long when) Use the current |
abstract void | setAlpha(int alpha) Specify an alpha value for the drawable. 定义drawable的透明度 |
void | setAutoMirrored(boolean mirrored) Set whether this Drawable is automatically mirrored when its layout direction is RTL (right-to left). 设置自动镜像 |
void | setBounds(int left, int top, int right, int bottom) Specify a bounding rectangle for the Drawable. 定义Drawable的约束矩形 |
void | setBounds(Rect bounds) Specify a bounding rectangle for the Drawable. 定义Drawable的约束矩形 |
final void | setCallback(Drawable.Callback cb) Bind a 给Drawable绑定 |
void | setChangingConfigurations(int configs) Set a mask of the configuration parameters for which this drawable may change, requiring that it be re-created. |
void | setColorFilter(int color, PorterDuff.Mode mode) Specify a color and Porter-Duff mode to be the color filter for this drawable. |
abstract void | setColorFilter(ColorFilter colorFilter) Specify an optional color filter for the drawable. |
void | setDither(boolean dither) This method was deprecated in API level 23. This property is ignored. |
void | setFilterBitmap(boolean filter) Set to true to have the drawable filter its bitmaps with bilinear sampling when they are scaled or rotated. |
void | setHotspot(float x, float y) Specifies the hotspot's location within the drawable. |
void | setHotspotBounds(int left, int top, int right, int bottom) Sets the bounds to which the hotspot is constrained, if they should be different from the drawable bounds. |
final boolean | setLayoutDirection(int layoutDirection) Set the layout direction for this drawable. |
final boolean | setLevel(int level) Specify the level for the drawable. |
boolean | setState(int[] stateSet) Specify a set of states for the drawable. |
void | setTint(int tintColor) Specifies tint color for this drawable. |
void | setTintList(ColorStateList tint) Specifies tint color for this drawable as a color state list. |
void | setTintMode(PorterDuff.Mode tintMode) Specifies a tint blending mode for this drawable. |
boolean | setVisible(boolean visible, boolean restart) Set whether this Drawable is visible. |
void | unscheduleSelf(Runnable what) Use the current |