当前位置: 首页>>代码示例>>Java>>正文


Java ColorStateList.getDefaultColor方法代码示例

本文整理汇总了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;
}
 
开发者ID:universum-studios,项目名称:android_ui,代码行数:25,代码来源:MonthView.java

示例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();
		}
	}
}
 
开发者ID:LingjuAI,项目名称:AssistantBySDK,代码行数:34,代码来源:SwitchButton.java

示例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
    });
}
 
开发者ID:ximsfei,项目名称:Android-skin-support,代码行数:20,代码来源:SkinMaterialBottomNavigationView.java

示例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;
}
 
开发者ID:philliphsu,项目名称:NumberPadTimePicker,代码行数:21,代码来源:NumberPadTimePickerBottomSheetComponent.java

示例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;
}
 
开发者ID:PaulKlinger,项目名称:Sprog-App,代码行数:9,代码来源:TouchableUrlSpan.java

示例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);
    }
}
 
开发者ID:chengkun123,项目名称:ReadMark,代码行数:11,代码来源:BannerView.java

示例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();
        }
    }
}
 
开发者ID:LanguidSheep,项目名称:sealtalk-android-master,代码行数:34,代码来源:SwitchButton.java

示例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();

}
 
开发者ID:tranleduy2000,项目名称:screenfilter,代码行数:9,代码来源:MarkerDrawable.java

示例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();

}
 
开发者ID:dmllr,项目名称:IdealMedia,代码行数:9,代码来源:MarkerDrawable.java

示例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);
            }
        }
    }
}
 
开发者ID:Trumeet,项目名称:SetupWizardLibCompat,代码行数:16,代码来源:GlifLayout.java

示例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);
}
 
开发者ID:zacharee,项目名称:SliderPreferenceEmbedded,代码行数:12,代码来源:AlmostRippleDrawable.java

示例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);
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:29,代码来源:AppCompatDrawableManager.java

示例13: setTextColor

import android.content.res.ColorStateList; //导入方法依赖的package包/类
@Override
public void setTextColor(ColorStateList colors) {
    mTextColor = colors.getDefaultColor();
    super.setTextColor(colors);
}
 
开发者ID:enricocid,项目名称:LaunchEnr,代码行数:6,代码来源:BubbleTextView.java

示例14: setColorStateList

import android.content.res.ColorStateList; //导入方法依赖的package包/类
public void setColorStateList(@NonNull ColorStateList tintStateList) {
    mTintStateList = tintStateList;
    mCurrentColor = tintStateList.getDefaultColor();
}
 
开发者ID:DuanJiaNing,项目名称:Musicoco,代码行数:5,代码来源:StateDrawable.java

示例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;
    }
}
 
开发者ID:Pingsh,项目名称:Mix,代码行数:52,代码来源:ThemeUtils.java


注:本文中的android.content.res.ColorStateList.getDefaultColor方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。