本文整理汇总了Java中android.util.StateSet.WILD_CARD属性的典型用法代码示例。如果您正苦于以下问题:Java StateSet.WILD_CARD属性的具体用法?Java StateSet.WILD_CARD怎么用?Java StateSet.WILD_CARD使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类android.util.StateSet
的用法示例。
在下文中一共展示了StateSet.WILD_CARD属性的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setTextAccentColorInverse
void setTextAccentColorInverse(TextView view, int accentColor) {
final int pressedColor = getPressedColor(accentColor);
final int disabledColor = getDisabledColor(accentColor);
final int[][] states = new int[][]{
new int[]{android.R.attr.state_pressed, android.R.attr.state_enabled},
new int[]{android.R.attr.state_focused, android.R.attr.state_enabled},
new int[]{-android.R.attr.state_enabled},
StateSet.WILD_CARD
};
final int[] colors = new int[]{pressedColor, pressedColor, disabledColor, accentColor};
final ColorStateList stateList = new ColorStateList(states, colors);
view.setTextColor(stateList);
}
示例2: generateDefaultTrackColorStateListFromTheme
public static ColorStateList generateDefaultTrackColorStateListFromTheme(Context context) {
int[][] states = new int[][] {
SELECTED_STATE_SET,
ENABLED_STATE_SET,
StateSet.WILD_CARD
};
// This is an approximation of the track colors derived from Lollipop resources
boolean isLightTheme = Utils.isLightTheme(context);
int enabled = isLightTheme ? 0x28181818 : 0x85ffffff;
int[] colors = new int[] {
Utils.getThemeColor(context, android.R.attr.colorControlActivated),
enabled,
0x14181818 //TODO: get this from a theme attr?
};
return new ColorStateList(states, colors);
}
示例3: createIndetermColorStateList
private static ColorStateList createIndetermColorStateList(Context context) {
final int[][] states = new int[][]{
new int[]{-android.R.attr.state_enabled},
new int[]{R.attr.state_indeterminate},
new int[]{android.R.attr.state_checked},
StateSet.WILD_CARD
};
final int normal = resolveColor(context, R.attr.colorControlNormal, Color.DKGRAY);
final int activated = resolveColor(context, R.attr.colorControlActivated, Color.CYAN);
final float disabledAlpha = resolveFloat(context, android.R.attr.disabledAlpha, 0.25f);
final int[] colors = new int[]{
Utils.applyAlpha(normal, disabledAlpha),
normal,
activated,
normal
};
return new ColorStateList(states, colors);
}
示例4: createSimpleSelectorCircleDrawable
public static Drawable createSimpleSelectorCircleDrawable(int size, int defaultColor, int pressedColor) {
OvalShape ovalShape = new OvalShape();
ovalShape.resize(size, size);
ShapeDrawable defaultDrawable = new ShapeDrawable(ovalShape);
defaultDrawable.getPaint().setColor(defaultColor);
ShapeDrawable pressedDrawable = new ShapeDrawable(ovalShape);
if (Build.VERSION.SDK_INT >= 21) {
pressedDrawable.getPaint().setColor(0xffffffff);
ColorStateList colorStateList = new ColorStateList(
new int[][]{StateSet.WILD_CARD},
new int[]{pressedColor}
);
return new RippleDrawable(colorStateList, defaultDrawable, pressedDrawable);
} else {
pressedDrawable.getPaint().setColor(pressedColor);
StateListDrawable stateListDrawable = new StateListDrawable();
stateListDrawable.addState(new int[]{android.R.attr.state_pressed}, pressedDrawable);
stateListDrawable.addState(new int[]{android.R.attr.state_focused}, pressedDrawable);
stateListDrawable.addState(StateSet.WILD_CARD, defaultDrawable);
return stateListDrawable;
}
}
示例5: getRoundRectSelectorDrawable
public static Drawable getRoundRectSelectorDrawable() {
if (Build.VERSION.SDK_INT >= 21) {
Drawable maskDrawable = createRoundRectDrawable(AndroidUtilities.dp(3), 0xffffffff);
ColorStateList colorStateList = new ColorStateList(
new int[][]{StateSet.WILD_CARD},
new int[]{getColor(key_dialogButtonSelector)}
);
return new RippleDrawable(colorStateList, null, maskDrawable);
} else {
StateListDrawable stateListDrawable = new StateListDrawable();
stateListDrawable.addState(new int[]{android.R.attr.state_pressed}, createRoundRectDrawable(AndroidUtilities.dp(3), getColor(key_dialogButtonSelector)));
stateListDrawable.addState(new int[]{android.R.attr.state_selected}, createRoundRectDrawable(AndroidUtilities.dp(3), getColor(key_dialogButtonSelector)));
stateListDrawable.addState(StateSet.WILD_CARD, new ColorDrawable(0x00000000));
return stateListDrawable;
}
}
示例6: getSelectorDrawable
public static Drawable getSelectorDrawable(boolean whiteBackground) {
if (whiteBackground) {
if (Build.VERSION.SDK_INT >= 21) {
Drawable maskDrawable = new ColorDrawable(0xffffffff);
ColorStateList colorStateList = new ColorStateList(
new int[][]{StateSet.WILD_CARD},
new int[]{getColor(key_listSelector)}
);
return new RippleDrawable(colorStateList, new ColorDrawable(getColor(key_windowBackgroundWhite)), maskDrawable);
} else {
int color = getColor(key_listSelector);
StateListDrawable stateListDrawable = new StateListDrawable();
stateListDrawable.addState(new int[]{android.R.attr.state_pressed}, new ColorDrawable(color));
stateListDrawable.addState(new int[]{android.R.attr.state_selected}, new ColorDrawable(color));
stateListDrawable.addState(StateSet.WILD_CARD, new ColorDrawable(getColor(key_windowBackgroundWhite)));
return stateListDrawable;
}
} else {
return createSelectorDrawable(getColor(key_listSelector), 2);
}
}
示例7: createColorStateList
public static ColorStateList createColorStateList(int normal, int pressed) {
int[] colors = new int[]{pressed, pressed, pressed, normal};
int[][] states = new int[4][];
states[0] = new int[]{16842919};
states[1] = new int[]{16842913};
states[2] = new int[]{16842908};
states[3] = StateSet.WILD_CARD;
return new ColorStateList(states, colors);
}
示例8: createColorStateList
private static ColorStateList createColorStateList(Context context) {
return new ColorStateList(
new int[][]{
new int[]{-android.R.attr.state_enabled}, // Disabled state.
StateSet.WILD_CARD, // Enabled state.
},
new int[]{
getThemeAttrColor(context, R.attr.colorAccent), // Disabled state.
getThemeAttrColor(context, R.attr.colorPrimary), // Enabled state.
});
}
示例9: setTextAccentColor
void setTextAccentColor(TextView view, int accentColor) {
final int enabledColor = getTextColor(accentColor);
final int disabledColor = getDisabledColor(enabledColor);
final int[][] states = new int[][]{
new int[]{-android.R.attr.state_enabled}, //For completeness. Currently unused
StateSet.WILD_CARD
};
final int[] colors = new int[]{disabledColor, enabledColor};
final ColorStateList stateList = new ColorStateList(states, colors);
view.setTextColor(stateList);
}
示例10: generateDefaultColorStateListFromTheme
public static ColorStateList generateDefaultColorStateListFromTheme(Context context) {
int[][] states = new int[][] {
View.PRESSED_STATE_SET,
View.ENABLED_STATE_SET,
StateSet.WILD_CARD
};
int[] colors = new int[] {
Utils.getThemeColor(context, android.R.attr.colorControlActivated),
Utils.getThemeColor(context, android.R.attr.colorControlActivated),
0x42000000 //TODO: get this from a theme attr?
};
return new ColorStateList(states, colors);
}
示例11: createStateList
private List<Integer> createStateList(int[] stateSet) {
List<Integer> stateList = new ArrayList<Integer>();
if (stateSet == StateSet.WILD_CARD) {
stateList.add(-1);
} else {
for (int state : stateSet) {
stateList.add(state);
}
}
return stateList;
}
示例12: StateDrawable
public StateDrawable(Drawable normal, Drawable altered) {
this.normal = normal;
this.altered = altered;
this.checked = null;
this.checkedAltered = null;
this.hasChecks = false;
this.stateSet = StateSet.WILD_CARD;
computeCurrent();
}
示例13: createSelectorDrawable
public static Drawable createSelectorDrawable(int color, int maskType) {
Drawable drawable;
if (Build.VERSION.SDK_INT >= 21) {
Drawable maskDrawable = null;
if (maskType == 1) {
maskPaint.setColor(0xffffffff);
maskDrawable = new Drawable() {
@Override
public void draw(Canvas canvas) {
android.graphics.Rect bounds = getBounds();
canvas.drawCircle(bounds.centerX(), bounds.centerY(), AndroidUtilities.dp(18), maskPaint);
}
@Override
public void setAlpha(int alpha) {
}
@Override
public void setColorFilter(ColorFilter colorFilter) {
}
@Override
public int getOpacity() {
return PixelFormat.UNKNOWN;
}
};
} else if (maskType == 2) {
maskDrawable = new ColorDrawable(0xffffffff);
}
ColorStateList colorStateList = new ColorStateList(
new int[][]{StateSet.WILD_CARD},
new int[]{color}
);
return new RippleDrawable(colorStateList, null, maskDrawable);
} else {
StateListDrawable stateListDrawable = new StateListDrawable();
stateListDrawable.addState(new int[]{android.R.attr.state_pressed}, new ColorDrawable(color));
stateListDrawable.addState(new int[]{android.R.attr.state_selected}, new ColorDrawable(color));
stateListDrawable.addState(StateSet.WILD_CARD, new ColorDrawable(0x00000000));
return stateListDrawable;
}
}