[6.3.0][View点击态] 优化可点击控件背景创建逻辑;修复因焦点变化造成的背景重影问题
This commit is contained in:
@@ -7,6 +7,7 @@ import android.graphics.Color;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.graphics.drawable.StateListDrawable;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.StateSet;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
@@ -533,7 +534,7 @@ public class ViewPressedStateLancet {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
states[1] = new int[] { -android.R.attr.state_pressed };
|
||||
states[1] = StateSet.WILD_CARD;
|
||||
colors[1] = defaultColor;
|
||||
}
|
||||
ColorStateList newColor = new ColorStateList(states, colors);
|
||||
@@ -601,11 +602,10 @@ public class ViewPressedStateLancet {
|
||||
Drawable.ConstantState constantState = old.getConstantState();
|
||||
if (constantState != null) {
|
||||
StateListDrawable result = new StateListDrawable();
|
||||
int[] state = { -android.R.attr.state_pressed };
|
||||
result.addState(state, old);
|
||||
Drawable pressed = DrawableCompat.wrap(constantState.newDrawable().mutate());
|
||||
pressed.setAlpha((int)(255 * alpha));
|
||||
result.addState(new int[] { android.R.attr.state_pressed }, pressed);
|
||||
result.addState(StateSet.WILD_CARD, old);
|
||||
return result;
|
||||
}
|
||||
return null;
|
||||
|
||||
Reference in New Issue
Block a user