Java Code Examples for android.graphics.drawable.Drawable#addState()

The following examples show how to use android.graphics.drawable.Drawable#addState() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CustomResourceMgmt.java    From letv with Apache License 2.0 6 votes vote down vote up
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;
}
 
Example 2
Source File: ImageActivity.java    From letv with Apache License 2.0 5 votes vote down vote up
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);
}
 
Example 3
Source File: CustomResourceMgmt.java    From letv with Apache License 2.0 5 votes vote down vote up
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;
}
 
Example 4
Source File: CustomResourceMgmt.java    From letv with Apache License 2.0 5 votes vote down vote up
public Drawable getCheckStatusDrawable(String origin, String checked, boolean is9Png) {
    int originId = this.mResources.getIdentifier(origin, "drawable", this.packageName);
    int selectId = this.mResources.getIdentifier(checked, "drawable", this.packageName);
    if (originId == 0 && selectId == 0) {
        String suffix = (is9Png ? ".9" : "") + ".png";
        return new StateListDrawableBuilder(this.mContext, "drawable/" + origin + suffix).setCheckedDrawable("drawable/" + checked + suffix).create();
    }
    Drawable mStateListDrawable = new StateListDrawable();
    mStateListDrawable.addState(new int[]{16842912}, this.mResources.getDrawable(selectId));
    mStateListDrawable.addState(new int[0], this.mResources.getDrawable(originId));
    return mStateListDrawable;
}