本文整理匯總了Java中android.content.res.ColorStateList.isStateful方法的典型用法代碼示例。如果您正苦於以下問題:Java ColorStateList.isStateful方法的具體用法?Java ColorStateList.isStateful怎麽用?Java ColorStateList.isStateful使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.content.res.ColorStateList
的用法示例。
在下文中一共展示了ColorStateList.isStateful方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: updateDayNumberTextColors
import android.content.res.ColorStateList; //導入方法依賴的package包/類
/**
* Updates colors for different states hold by {@link #DAY_NUMBERS_COLORS_STATE} from the current
* {@link ColorStateList} specified via {@link #setDayNumberTextColor(ColorStateList)}.
*
* @return {@code True} if at least one color has been changed so invalidation of day numbers
* area is needed, {@code false} otherwise.
*/
private boolean updateDayNumberTextColors() {
final ColorStateList colors = DAY_NUMBER_TEXT_INFO.mAppearance.getTextColor();
int defColor = DayNumberColorsState.DEF_COLOR;
if (colors.isStateful()) {
defColor = colors.getDefaultColor();
DAY_NUMBERS_COLORS_STATE.dayNumberColorNormal = colors.getColorForState(WidgetStateSet.ENABLED, defColor);
DAY_NUMBERS_COLORS_STATE.dayNumberColorPressed = colors.getColorForState(WidgetStateSet.ENABLED_PRESSED, defColor);
DAY_NUMBERS_COLORS_STATE.dayNumberColorSelected = colors.getColorForState(WidgetStateSet.ENABLED_SELECTED, defColor);
DAY_NUMBERS_COLORS_STATE.dayNumberColorDisabled = colors.getColorForState(WidgetStateSet.DISABLED, defColor);
} else {
DAY_NUMBERS_COLORS_STATE.dayNumberColorNormal = defColor;
DAY_NUMBERS_COLORS_STATE.dayNumberColorPressed = defColor;
DAY_NUMBERS_COLORS_STATE.dayNumberColorSelected = defColor;
DAY_NUMBERS_COLORS_STATE.dayNumberColorDisabled = defColor;
}
return true;
}
示例2: isStateful
import android.content.res.ColorStateList; //導入方法依賴的package包/類
/**
*/
@Override
public boolean isStateful() {
if (mDrawableLayerTints == null) {
return super.isStateful();
}
for (int i = 0; i < mDrawableLayerTints.size(); i++) {
final ColorStateList tintList = mDrawableLayerTints.valueAt(i).tintList;
if (tintList != null && tintList.isStateful()) {
return true;
}
}
return super.isStateful();
}
示例3: getThemeColorStateList
import android.content.res.ColorStateList; //導入方法依賴的package包/類
public static ColorStateList getThemeColorStateList(Context context, ColorStateList origin) {
if (origin == null) return null;
if (origin.isStateful()) {
TintInfo tintInfo = parseColorStateList(origin);
if (tintInfo == null || tintInfo.isInvalid()) {
return origin;
}
int[] newColors;
int[][] newStates;
int index = 0;
boolean hasDisableColor = StateSet.stateSetMatches(tintInfo.mTintStates[0], DISABLED_STATE_SET);
if (!hasDisableColor) {
newStates = new int[tintInfo.mTintStates.length + 1][];
newColors = new int[tintInfo.mTintStates.length + 1];
newStates[index] = DISABLED_STATE_SET;
newColors[index] = getDisabledThemeAttrColor(context, R.attr.themeColorSecondary);
index++;
} else {
newStates = new int[tintInfo.mTintStates.length][];
newColors = new int[tintInfo.mTintStates.length];
}
for (int i = 0; i < tintInfo.mTintStates.length; i++) {
newStates[index] = tintInfo.mTintStates[i];
newColors[index] = replaceColor(context, tintInfo.mTintColors[i]);
index++;
}
return new ColorStateList(newStates, newColors);
}
return ColorStateList.valueOf(replaceColor(context, origin.getDefaultColor()));
}
示例4: createSwitchThumbColorStateList
import android.content.res.ColorStateList; //導入方法依賴的package包/類
private ColorStateList createSwitchThumbColorStateList(Context context) {
int[][] states = new int[3][];
int[] colors = new int[3];
ColorStateList thumbColor = ThemeUtils.getThemeAttrColorStateList(context, R.attr.colorSwitchThumbNormal);
int i;
if (thumbColor == null || !thumbColor.isStateful()) {
states[0] = ThemeUtils.DISABLED_STATE_SET;
colors[0] = ThemeUtils.getDisabledThemeAttrColor(context, R.attr.colorSwitchThumbNormal);
i = 0 + 1;
states[i] = ThemeUtils.CHECKED_STATE_SET;
colors[i] = ThemeUtils.getThemeAttrColor(context, R.attr.colorControlActivated);
i++;
states[i] = ThemeUtils.EMPTY_STATE_SET;
colors[i] = ThemeUtils.getThemeAttrColor(context, R.attr.colorSwitchThumbNormal);
i++;
} else {
states[0] = ThemeUtils.DISABLED_STATE_SET;
colors[0] = thumbColor.getColorForState(states[0], 0);
i = 0 + 1;
states[i] = ThemeUtils.CHECKED_STATE_SET;
colors[i] = ThemeUtils.getThemeAttrColor(context, R.attr.colorControlActivated);
i++;
states[i] = ThemeUtils.EMPTY_STATE_SET;
colors[i] = thumbColor.getDefaultColor();
i++;
}
return new ColorStateList(states, colors);
}
示例5: getDisabledThemeAttrColor
import android.content.res.ColorStateList; //導入方法依賴的package包/類
public static int getDisabledThemeAttrColor(Context context, int attr) {
ColorStateList csl = getThemeAttrColorStateList(context, attr);
if (csl != null && csl.isStateful()) {
return csl.getColorForState(DISABLED_STATE_SET, csl.getDefaultColor());
}
TypedValue tv = getTypedValue();
context.getTheme().resolveAttribute(16842803, tv, true);
return getThemeAttrColor(context, attr, tv.getFloat());
}
示例6: isStateful
import android.content.res.ColorStateList; //導入方法依賴的package包/類
public boolean isStateful() {
ColorStateList tintList = isCompatTintEnabled() ? this.mState.mTint : null;
return (tintList != null && tintList.isStateful()) || this.mDrawable.isStateful();
}
示例7: resolveColorForState
import android.content.res.ColorStateList; //導入方法依賴的package包/類
/**
* Obtains a color from the specified <var>colorStateList</var> for the specified <var>stateSet</var>.
*
* @param colorStateList The colors state list from which to obtain the color.
* @param stateSet The state set used to resolved the color.
* @return Resolved color for the state or the default one if the colors state list does not hold
* color for the specified state.
*/
@ColorInt
public static int resolveColorForState(@NonNull ColorStateList colorStateList, @NonNull int[] stateSet) {
return colorStateList.isStateful() ?
colorStateList.getColorForState(stateSet, colorStateList.getDefaultColor()) :
colorStateList.getDefaultColor();
}