List of usage examples for android.graphics.drawable StateListDrawable addState
public void addState(int[] stateSet, Drawable drawable)
From source file:Main.java
public static StateListDrawable getCheckedSelectorDrawable(Drawable normal, Drawable pressed) { StateListDrawable bg = new StateListDrawable(); bg.addState(new int[] { android.R.attr.state_checked, android.R.attr.state_enabled }, pressed); bg.addState(new int[] { android.R.attr.state_enabled }, normal); bg.addState(new int[] {}, normal); return bg;//from ww w .j ava 2s. c om }
From source file:Main.java
public static StateListDrawable getPressedSelectorDrawable(Drawable normal, Drawable pressed) { StateListDrawable bg = new StateListDrawable(); bg.addState(new int[] { android.R.attr.state_pressed, android.R.attr.state_enabled }, pressed); bg.addState(new int[] { android.R.attr.state_enabled }, normal); bg.addState(new int[] {}, normal); return bg;/*w w w. j ava2s . co m*/ }
From source file:Main.java
public static StateListDrawable createSelector(Drawable normalState, Drawable pressedState) { StateListDrawable bg = new StateListDrawable(); bg.addState(new int[] { android.R.attr.state_pressed, android.R.attr.state_enabled }, pressedState); bg.addState(new int[] { android.R.attr.state_enabled }, normalState); bg.addState(new int[] {}, normalState); return bg;//from ww w.j a va2 s . c om }
From source file:Main.java
public static StateListDrawable getDrawable(Drawable normal, Drawable pressed) { StateListDrawable sd = new StateListDrawable(); sd.addState(new int[] { android.R.attr.state_pressed }, pressed); sd.addState(new int[] { android.R.attr.state_enabled }, normal); sd.addState(new int[] {}, pressed); return sd;/* w ww . j a va 2 s . c om*/ }
From source file:Main.java
public static StateListDrawable crealeLableSelector(Drawable normalDrawable, Drawable pressedDrawable) { StateListDrawable selector = new StateListDrawable(); selector.addState(new int[] { android.R.attr.state_pressed }, pressedDrawable); selector.addState(new int[] {}, normalDrawable); return selector; }
From source file:Main.java
public static Drawable getSelectedStateDrawable(Drawable normal, Drawable selected) { StateListDrawable drawable = new StateListDrawable(); drawable.addState(new int[] { -android.R.attr.state_selected }, normal); drawable.addState(new int[] { android.R.attr.state_selected }, selected); return drawable; }
From source file:Main.java
/** * helper to create a StateListDrawable for the drawer item background * * @param selected_color// w w w . j a va2 s . co m * @return */ public static StateListDrawable getDrawerItemBackground(int selected_color) { ColorDrawable clrActive = new ColorDrawable(selected_color); StateListDrawable states = new StateListDrawable(); states.addState(new int[] { android.R.attr.state_selected }, clrActive); return states; }
From source file:Main.java
public static StateListDrawable selector(int color) { StateListDrawable drawable = new StateListDrawable(); drawable.addState(new int[] { android.R.attr.state_pressed }, getColorDrawable(color)); drawable.addState(new int[] { android.R.attr.state_focused }, getColorDrawable(color)); drawable.addState(new int[] { android.R.attr.state_selected }, getColorDrawable(color)); drawable.addState(new int[] { android.R.attr.state_activated }, getColorDrawable(color)); return drawable; }
From source file:Main.java
public static StateListDrawable getSelector(Drawable normalDraw, Drawable pressedDraw) { StateListDrawable stateListDrawable = new StateListDrawable(); stateListDrawable.addState(new int[] { android.R.attr.state_enabled }, pressedDraw); stateListDrawable.addState(new int[] {}, normalDraw); return stateListDrawable; }
From source file:Main.java
public static StateListDrawable bgColorDrawableSelector(Bitmap nomal, Bitmap focus) { BitmapDrawable nomalBitmap = new BitmapDrawable(nomal); BitmapDrawable focusBitmap = new BitmapDrawable(focus); StateListDrawable selector = new StateListDrawable(); selector.addState(new int[] { android.R.attr.state_pressed }, focusBitmap); selector.addState(new int[] { android.R.attr.state_selected }, focusBitmap); selector.addState(new int[] { android.R.attr.state_focused }, focusBitmap); selector.addState(new int[] {}, nomalBitmap); return selector; }