本文整理汇总了Java中android.content.res.ColorStateList.getDefaultColor方法的典型用法代码示例。如果您正苦于以下问题:Java ColorStateList.getDefaultColor方法的具体用法?Java ColorStateList.getDefaultColor怎么用?Java ColorStateList.getDefaultColor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.content.res.ColorStateList
的用法示例。
在下文中一共展示了ColorStateList.getDefaultColor方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: drawableStateChanged
import android.content.res.ColorStateList; //导入方法依赖的package包/类
@Override
protected void drawableStateChanged() {
super.drawableStateChanged();
if (!mIsThumbUseDrawable && mThumbColor != null) {
mCurrThumbColor = mThumbColor.getColorForState(getDrawableState(), mCurrThumbColor);
} else {
setDrawableState(mThumbDrawable);
}
int[] nextState = isChecked() ? UNCHECKED_PRESSED_STATE : CHECKED_PRESSED_STATE;
ColorStateList textColors = getTextColors();
if (textColors != null) {
int defaultTextColor = textColors.getDefaultColor();
mOnTextColor = textColors.getColorForState(CHECKED_PRESSED_STATE, defaultTextColor);
mOffTextColor = textColors.getColorForState(UNCHECKED_PRESSED_STATE, defaultTextColor);
}
if (!mIsBackUseDrawable && mBackColor != null) {
mCurrBackColor = mBackColor.getColorForState(getDrawableState(), mCurrBackColor);
mNextBackColor = mBackColor.getColorForState(nextState, mCurrBackColor);
} else {
if (mBackDrawable instanceof StateListDrawable && mFadeBack) {
mBackDrawable.setState(nextState);
mNextBackDrawable = mBackDrawable.getCurrent().mutate();
} else {
mNextBackDrawable = null;
}
setDrawableState(mBackDrawable);
if (mBackDrawable != null) {
mCurrentBackDrawable = mBackDrawable.getCurrent().mutate();
}
}
}
示例3: createDefaultColorStateList
import android.content.res.ColorStateList; //导入方法依赖的package包/类
private ColorStateList createDefaultColorStateList(int baseColorThemeAttr) {
final TypedValue value = new TypedValue();
if (!getContext().getTheme().resolveAttribute(baseColorThemeAttr, value, true)) {
return null;
}
ColorStateList baseColor = SkinCompatResources.getColorStateList(getContext(), value.resourceId);
int colorPrimary = SkinCompatResources.getColor(getContext(), mDefaultTintResId);
int defaultColor = baseColor.getDefaultColor();
return new ColorStateList(new int[][]{
DISABLED_STATE_SET,
CHECKED_STATE_SET,
EMPTY_STATE_SET
}, new int[]{
baseColor.getColorForState(DISABLED_STATE_SET, defaultColor),
colorPrimary,
defaultColor
});
}
示例4: extractColors
import android.content.res.ColorStateList; //导入方法依赖的package包/类
@NonNull
private static int[] extractColors(ColorStateList colorStateList, int[][] states) {
int[] colors = new int[states.length];
int idx = 0;
for (int[] stateSet : states) {
// The empty state is peculiar in that getColorForState() will not return
// the default color, but rather any color defined in the ColorStateList
// for any state.
// https://developer.android.com/reference/android/content/res/ColorStateList.html
// "Each item defines a set of state spec and color pairs, where the state
// spec is a series of attributes set to either true or false to represent
// inclusion or exclusion. If an attribute is not specified for an item,
// it may be any value."
// "An item with no state spec is considered to match any set of states
// and is generally useful as a final item to be used as a default."
colors[idx++] = stateSet.length == 0 ? colorStateList.getDefaultColor()
: colorStateList.getColorForState(stateSet, 0);
}
return colors;
}
示例5: TouchableUrlSpan
import android.content.res.ColorStateList; //导入方法依赖的package包/类
public TouchableUrlSpan(String url,
ColorStateList textColor,
int pressedBackgroundColor) {
super(url);
this.normalTextColor = textColor.getDefaultColor();
this.pressedTextColor = textColor.getColorForState(STATE_PRESSED, normalTextColor);
this.pressedBackgroundColor = pressedBackgroundColor;
}
示例6: setBannerDotColor
import android.content.res.ColorStateList; //导入方法依赖的package包/类
/**
* 设置DOtView的focus时的颜色
* @param color
*/
public void setBannerDotColor(ColorStateList color){
mIndicatorFocusDrawable = new ColorDrawable(color.getDefaultColor());
if(mCurrentDot != null) {
mCurrentDot.setDrawable(mIndicatorFocusDrawable);
}
}
示例7: drawableStateChanged
import android.content.res.ColorStateList; //导入方法依赖的package包/类
@Override
protected void drawableStateChanged() {
super.drawableStateChanged();
if (!mIsThumbUseDrawable && mThumbColor != null) {
mCurrThumbColor = mThumbColor.getColorForState(getDrawableState(), mCurrThumbColor);
} else {
setDrawableState(mThumbDrawable);
}
int[] nextState = isChecked() ? UNCHECKED_PRESSED_STATE : CHECKED_PRESSED_STATE;
ColorStateList textColors = getTextColors();
if (textColors != null) {
int defaultTextColor = textColors.getDefaultColor();
mOnTextColor = textColors.getColorForState(CHECKED_PRESSED_STATE, defaultTextColor);
mOffTextColor = textColors.getColorForState(UNCHECKED_PRESSED_STATE, defaultTextColor);
}
if (!mIsBackUseDrawable && mBackColor != null) {
mCurrBackColor = mBackColor.getColorForState(getDrawableState(), mCurrBackColor);
mNextBackColor = mBackColor.getColorForState(nextState, mCurrBackColor);
} else {
if (mBackDrawable instanceof StateListDrawable && mFadeBack) {
mBackDrawable.setState(nextState);
mNextBackDrawable = mBackDrawable.getCurrent().mutate();
} else {
mNextBackDrawable = null;
}
setDrawableState(mBackDrawable);
if (mBackDrawable != null) {
mCurrentBackDrawable = mBackDrawable.getCurrent().mutate();
}
}
}
示例8: MarkerDrawable
import android.content.res.ColorStateList; //导入方法依赖的package包/类
public MarkerDrawable(@NonNull ColorStateList tintList, int closedSize) {
super(tintList);
mInterpolator = new AccelerateDecelerateInterpolator();
mClosedStateSize = closedSize;
mStartColor = tintList.getColorForState(new int[]{android.R.attr.state_enabled, android.R.attr.state_pressed}, tintList.getDefaultColor());
mEndColor = tintList.getDefaultColor();
}
示例9: MarkerDrawable
import android.content.res.ColorStateList; //导入方法依赖的package包/类
public MarkerDrawable(@NonNull ColorStateList tintList, int closedSize) {
super(tintList);
mInterpolator = new AccelerateDecelerateInterpolator();
mClosedStateSize = closedSize;
mStartColor = tintList.getColorForState(new int[]{android.R.attr.state_pressed}, tintList.getDefaultColor());
mEndColor = tintList.getDefaultColor();
}
示例10: setGlifPatternColor
import android.content.res.ColorStateList; //导入方法依赖的package包/类
private void setGlifPatternColor(ColorStateList color) {
if (Build.VERSION.SDK_INT >= VERSION_CODES.LOLLIPOP) {
setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
final View patternBg = findManagedViewById(R.id.suw_pattern_bg);
if (patternBg != null) {
final GlifPatternDrawable background =
new GlifPatternDrawable(color.getDefaultColor());
if (patternBg instanceof StatusBarBackgroundLayout) {
((StatusBarBackgroundLayout) patternBg).setStatusBarBackground(background);
} else {
patternBg.setBackground(background);
}
}
}
}
示例11: setColor
import android.content.res.ColorStateList; //导入方法依赖的package包/类
public void setColor(@NonNull ColorStateList tintStateList) {
int defaultColor = tintStateList.getDefaultColor();
mFocusedColor = tintStateList.getColorForState(new int[]{android.R.attr.state_enabled, android.R.attr.state_focused}, defaultColor);
mPressedColor = tintStateList.getColorForState(new int[]{android.R.attr.state_enabled, android.R.attr.state_pressed}, defaultColor);
mDisabledColor = tintStateList.getColorForState(new int[]{-android.R.attr.state_enabled}, defaultColor);
//The ripple should be partially transparent
mFocusedColor = getModulatedAlphaColor(130, mFocusedColor);
mPressedColor = getModulatedAlphaColor(130, mPressedColor);
mDisabledColor = getModulatedAlphaColor(130, mDisabledColor);
}
示例12: 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);
}
示例13: setTextColor
import android.content.res.ColorStateList; //导入方法依赖的package包/类
@Override
public void setTextColor(ColorStateList colors) {
mTextColor = colors.getDefaultColor();
super.setTextColor(colors);
}
示例14: setColorStateList
import android.content.res.ColorStateList; //导入方法依赖的package包/类
public void setColorStateList(@NonNull ColorStateList tintStateList) {
mTintStateList = tintStateList;
mCurrentColor = tintStateList.getDefaultColor();
}
示例15: parseColorStateList
import android.content.res.ColorStateList; //导入方法依赖的package包/类
static TintInfo parseColorStateList(ColorStateList origin) {
if (origin == null) return null;
boolean hasDisable = false;
int originDefaultColor = origin.getDefaultColor();
LinkedList<int[]> stateList = new LinkedList<>();
LinkedList<Integer> colorList = new LinkedList<>();
int disableColor = origin.getColorForState(DISABLED_STATE_SET, 0);
if (disableColor != originDefaultColor) {
hasDisable = true;
stateList.add(DISABLED_STATE_SET);
colorList.add(disableColor);
}
int pressedColor = origin.getColorForState(wrapState(hasDisable, PRESSED_STATE_SET), 0);
if (pressedColor != originDefaultColor) {
stateList.add(PRESSED_STATE_SET);
colorList.add(pressedColor);
}
int focusColor = origin.getColorForState(wrapState(hasDisable, FOCUSED_STATE_SET), 0);
if (focusColor != originDefaultColor) {
stateList.add(FOCUSED_STATE_SET);
colorList.add(focusColor);
}
int checkedColor = origin.getColorForState(wrapState(hasDisable, CHECKED_STATE_SET), 0);
if (checkedColor != originDefaultColor) {
stateList.add(CHECKED_STATE_SET);
colorList.add(checkedColor);
}
int selectedColor = origin.getColorForState(wrapState(hasDisable, SELECTED_STATE_SET), 0);
if (selectedColor != originDefaultColor) {
stateList.add(SELECTED_STATE_SET);
colorList.add(selectedColor);
}
int normalColor = origin.getColorForState(wrapState(hasDisable, EMPTY_STATE_SET), 0);
if (normalColor != 0) {
stateList.add(EMPTY_STATE_SET);
colorList.add(normalColor);
}
if (colorList.size() > 1) {
return new TintInfo(stateList, colorList);
} else {
return null;
}
}