本文整理匯總了Java中android.graphics.drawable.Drawable.addState方法的典型用法代碼示例。如果您正苦於以下問題:Java Drawable.addState方法的具體用法?Java Drawable.addState怎麽用?Java Drawable.addState使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.graphics.drawable.Drawable
的用法示例。
在下文中一共展示了Drawable.addState方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getCheckStatusDrawable
import android.graphics.drawable.Drawable; //導入方法依賴的package包/類
public Drawable getCheckStatusDrawable(String origin, String checked, String pressed, String checkpressed, boolean is9Png) {
int originId = this.mResources.getIdentifier(origin, "drawable", this.packageName);
int selectId = this.mResources.getIdentifier(checked, "drawable", this.packageName);
int pressedId = this.mResources.getIdentifier(pressed, "drawable", this.packageName);
int selectpressId = this.mResources.getIdentifier(checkpressed, "drawable", this.packageName);
if (originId == 0 && selectId == 0 && pressedId == 0 && selectpressId == 0) {
String suffix = (is9Png ? ".9" : "") + ".png";
return new StateListDrawableBuilder(this.mContext, "drawable/" + origin + suffix).setPressDrawable("drawable/" + pressed + suffix).setCheckedDrawable("drawable/" + checked + suffix).setPressCheckedDrawable("drawable/" + checkpressed + suffix).create();
}
Drawable mStateListDrawable = new StateListDrawable();
mStateListDrawable.addState(new int[]{16842912}, this.mResources.getDrawable(selectId));
mStateListDrawable.addState(new int[]{16842919}, this.mResources.getDrawable(pressedId));
mStateListDrawable.addState(new int[]{16842919, 16842912}, this.mResources.getDrawable(selectpressId));
mStateListDrawable.addState(new int[0], this.mResources.getDrawable(originId));
return mStateListDrawable;
}
示例2: b
import android.graphics.drawable.Drawable; //導入方法依賴的package包/類
public void b(Button button) {
Drawable stateListDrawable = new StateListDrawable();
Drawable a = this.a.b("com.tencent.plus.gray_normal.png");
Drawable a2 = this.a.b("com.tencent.plus.gray_down.png");
Drawable a3 = this.a.b("com.tencent.plus.gray_disable.png");
stateListDrawable.addState(View.PRESSED_ENABLED_STATE_SET, a2);
stateListDrawable.addState(View.ENABLED_FOCUSED_STATE_SET, a);
stateListDrawable.addState(View.ENABLED_STATE_SET, a);
stateListDrawable.addState(View.FOCUSED_STATE_SET, a);
stateListDrawable.addState(View.EMPTY_STATE_SET, a3);
button.setBackgroundDrawable(stateListDrawable);
}
示例3: getStatusDrawable
import android.graphics.drawable.Drawable; //導入方法依賴的package包/類
public Drawable getStatusDrawable(String origin, String press, boolean is9Png) {
int originId = this.mResources.getIdentifier(origin, "drawable", this.packageName);
int pressId = this.mResources.getIdentifier(press, "drawable", this.packageName);
if (originId == 0 && pressId == 0) {
String suffix = (is9Png ? ".9" : "") + ".png";
return new StateListDrawableBuilder(this.mContext, "drawable/" + origin + suffix).setPressDrawable("drawable/" + press + suffix).create();
}
Drawable mStateListDrawable = new StateListDrawable();
mStateListDrawable.addState(new int[]{16842919, 16842910}, this.mResources.getDrawable(pressId));
mStateListDrawable.addState(new int[0], this.mResources.getDrawable(originId));
return mStateListDrawable;
}