當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。