private boolean defaultTheme;
private Context mContext;
public ViewStateListDrawable(Context context,
boolean defaultTheme) {
this.mContext = context;
this.defaultTheme = defaultTheme;
this.addStateDrawable();
}
@SuppressWarnings("deprecation")
private void addStateDrawable() {
Drawable normal = null;
Drawable pressed = null;
Drawable focus = null;
if (defaultTheme) {
//v_selector_btn_session
normal = mContext.getResources().getDrawable(R.drawable.v_session_button_normal);
pressed = mContext.getResources().getDrawable(R.drawable.v_session_button_pressed);
focus = pressed;
} else {
normal = mContext.getResources().getDrawable(R.drawable.wave_session_button_normal);
pressed = mContext.getResources().getDrawable(R.drawable.wave_session_button_pressed);
focus = pressed;
}
this.addState(new int[] {
android.R.attr.state_enabled, android.R.attr.state_focused
}, focus);
this.addState(new int[] {
android.R.attr.state_pressed, android.R.attr.state_enabled
}, pressed);
this.addState(new int[] {
android.R.attr.state_focused
}, focus);
this.addState(new int[] {
android.R.attr.state_pressed
}, pressed);
this.addState(new int[] {
android.R.attr.state_selected
}, pressed);
this.addState(new int[] {
android.R.attr.state_enabled
}, normal);
this.addState(new int[] {}, normal);
}
自定义selectorDrawable
最新推荐文章于 2021-10-27 10:39:46 发布