public static abstract class Drawable.ConstantState
extends Object
| java.lang.Object | |
| android.graphics.drawable.Drawable.ConstantState | |
| |
这个抽象类被Drawable用来存储Drawable之间的共享常量状态和数据。 BitmapDrawable从相同资源创建的BitmapDrawable将共享存储在其ConstantState中的唯一位图。
可以使用 newDrawable(Resources)作为工厂从此ConstantState创建新的Drawable实例。
getConstantState() to retrieve the ConstantState of a Drawable. Calling
mutate() on a Drawable should typically create a new ConstantState for that Drawable.
Public constructors |
|
|---|---|
Drawable.ConstantState() |
|
公共方法(Public methods) |
|
|---|---|
boolean |
canApplyTheme() 返回这个常量状态是否可以应用主题。 |
abstract int |
getChangingConfigurations() 返回将影响此可绘制的配置更改的位掩码(因此需要完全重新加载它)。 |
Drawable |
newDrawable(Resources res) 使用指定的资源从其常量状态创建一个新的Drawable实例。 |
abstract Drawable |
newDrawable() 从其常量状态创建一个新的Drawable实例。 |
Drawable |
newDrawable(Resources res, Resources.Theme theme) 使用指定的资源和主题,从其常量状态创建一个新的Drawable实例。 |
继承方法(Inherited methods) |
|
|---|---|
java.lang.Object
|
|
int getChangingConfigurations ()
返回将影响此可绘制的配置更改的位掩码(因此需要完全重新加载它)。
| 返回(Returns) | |
|---|---|
int |
|
Drawable newDrawable (Resources res)
使用指定的资源从其常量状态创建一个新的Drawable实例。 应该为具有密度依赖属性的drawable执行此方法。
此方法的默认实现调用至 newDrawable() 。
| 参数(Parameters) | |
|---|---|
res |
Resources: the resources of the context in which the drawable will be displayed |
| 返回(Returns) | |
|---|---|
Drawable |
a new drawable object based on this constant state |
Drawable newDrawable ()
从其常量状态创建一个新的Drawable实例。
注意:使用此方法意味着与像密度相关的属性(如像素尺寸或位图图像)不会更新以匹配目标显示的密度。 为确保正确缩放,请使用newDrawable(Resources)来代替提供适当的资源对象。
| 返回(Returns) | |
|---|---|
Drawable |
a new drawable object based on this constant state |
Drawable newDrawable (Resources res, Resources.Theme theme)
使用指定的资源和主题,从其常量状态创建一个新的Drawable实例。 应该为具有主题相关属性的可绘制实现此方法。
此方法的默认实现调用至 newDrawable(Resources) 。
| 参数(Parameters) | |
|---|---|
res |
Resources: the resources of the context in which the drawable will be displayed |
theme |
Resources.Theme: the theme of the context in which the drawable will be displayed |
| 返回(Returns) | |
|---|---|
Drawable |
a new drawable object based on this constant state |