當前位置: 首頁>>代碼示例>>Java>>正文


Java ColorStateList類代碼示例

本文整理匯總了Java中android.content.res.ColorStateList的典型用法代碼示例。如果您正苦於以下問題:Java ColorStateList類的具體用法?Java ColorStateList怎麽用?Java ColorStateList使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


ColorStateList類屬於android.content.res包,在下文中一共展示了ColorStateList類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: walkroundActionMenuTextColor

import android.content.res.ColorStateList; //導入依賴的package包/類
public static void walkroundActionMenuTextColor(Resources res){
    try {
        if (Build.VERSION.SDK_INT>=16 && Build.VERSION.SDK_INT <= 19) {
            final long key = (((long) -1) << 32) | 0x7f010082;
            if(walkroundStateList==null) {
                walkroundStateList = ColorStateList.valueOf(Color.rgb(0, 0, 0));
            }
            Field mColorStateListCacheField = AndroidHack.findField(res, "mColorStateListCache");
            mColorStateListCacheField.setAccessible(true);
            LongSparseArray mColorStateListCache = (LongSparseArray) mColorStateListCacheField.get(res);
            mColorStateListCache.put(key,new WeakReference<>(walkroundStateList));
        }
    }catch(Throwable e){
        e.printStackTrace();
    }
}
 
開發者ID:alibaba,項目名稱:atlas,代碼行數:17,代碼來源:DelegateResources.java

示例2: setWeekDayIconAndTitle

import android.content.res.ColorStateList; //導入依賴的package包/類
private void setWeekDayIconAndTitle(HeaderViewHolder viewHolder, int iconRes, String title) {
    if (mDate.equals(WeekDayUtil.formatDate(DateUtil.getCurrentTime("yyyy-MM-dd")))){
        viewHolder.mUpdateTime.setText("今天");
        viewHolder.mUpdateTime.setTextColor(mContext.getResources().getColor(R.color.colorPrimary));
        viewHolder.mWeekDayText.setTextColor(mContext.getResources().getColor(R.color.colorPrimary));
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            viewHolder.mWeekDayIcon.setImageTintList(ColorStateList.valueOf(mContext.getResources().getColor(R.color.colorPrimary)));
        }
    } else {
        viewHolder.mUpdateTime.setText(mDate);
        viewHolder.mUpdateTime.setTextColor(mContext.getResources().getColor(R.color.black_alpha_30));
        viewHolder.mWeekDayText.setTextColor(mContext.getResources().getColor(R.color.gray_80));
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            viewHolder.mWeekDayIcon.setImageTintList(ColorStateList.valueOf(mContext.getResources().getColor(R.color.gray_80)));
        }
    }
    viewHolder.mWeekDayIcon.setImageResource(iconRes);
    viewHolder.mWeekDayText.setText(title);
}
 
開發者ID:MUFCRyan,項目名稱:BilibiliClient,代碼行數:20,代碼來源:BangumiScheduleSection.java

示例3: colorMode

import android.content.res.ColorStateList; //導入依賴的package包/類
private void colorMode(int color) {
    if (getActivity() == null || getActivity().getWindow() == null) {
        return;
    }
    if (Extras.getInstance().getDarkTheme() || Extras.getInstance().getBlackTheme()) {
        getActivity().getWindow().setNavigationBarColor(color);
        getActivity().getWindow().setStatusBarColor(color);
        seekbar.setBackgroundTintList(ColorStateList.valueOf(color));
        if (vizualview != null) {
            vizualview.setmCakeColor(color);
        }
        playpausebutton.setBackgroundTintList(ColorStateList.valueOf(color));
        queueClick.setBackgroundTintList(ColorStateList.valueOf(color));
    } else {
        getActivity().getWindow().setNavigationBarColor(color);
        seekbar.setBackgroundTintList(ColorStateList.valueOf(color));
        getActivity().getWindow().setStatusBarColor(color);
        if (vizualview != null) {
            vizualview.setmCakeColor(color);
        }
        playpausebutton.setBackgroundTintList(ColorStateList.valueOf(color));
        queueClick.setBackgroundTintList(ColorStateList.valueOf(color));
    }

}
 
開發者ID:RajneeshSingh007,項目名稱:MusicX-music-player,代碼行數:26,代碼來源:Playing4Fragment.java

示例4: getPressedColorSelector

import android.content.res.ColorStateList; //導入依賴的package包/類
public static ColorStateList getPressedColorSelector(int normalColor, int pressedColor)
{
    return new ColorStateList(
            new int[][]
                    {
                            new int[]{android.R.attr.state_pressed},
                            new int[]{android.R.attr.state_focused},
                            new int[]{android.R.attr.state_activated},
                            new int[]{}
                    },
            new int[]
                    {
                            pressedColor,
                            pressedColor,
                            pressedColor,
                            normalColor
                    }
    );
}
 
開發者ID:florent37,項目名稱:Depth,代碼行數:20,代碼來源:RippleHelper.java

示例5: finishTask

import android.content.res.ColorStateList; //導入依賴的package包/類
@Override
public void finishTask() {
    mFAB.setClickable(true);
    mFAB.setBackgroundTintList(ColorStateList.valueOf(getResources().getColor(R.color.colorPrimary)));
    mCollapsingToolbarLayout.setTitle("");
    if (TextUtils.isEmpty(mImgUrl)){
        Glide.with(this)
                .load(mVideoDetailsInfo)
                .centerCrop()
                .diskCacheStrategy(DiskCacheStrategy.ALL)
                .placeholder(R.drawable.bili_default_image_tv)
                .dontAnimate()
                .into(mVideoPreview);
    }
    VideoIntroductionFragment introductionFragment = VideoIntroductionFragment.newInstance(mAv);
    VideoCommentFragment commentFragment = VideoCommentFragment.newInstance(mAv);
    fragments.add(introductionFragment);
    fragments.add(commentFragment);
    setPagerTitle(String.valueOf(mVideoDetailsInfo.getStat().getReply()));
}
 
開發者ID:MUFCRyan,項目名稱:BilibiliClient,代碼行數:21,代碼來源:VideoDetailsActivity.java

示例6: setTextColor

import android.content.res.ColorStateList; //導入依賴的package包/類
private void setTextColor(ColorStateList color) {
    if (this.mHeaderText != null) {
        this.mHeaderText.setTextColor(color);
    }
    if (this.mSubHeaderText != null) {
        this.mSubHeaderText.setTextColor(color);
    }
}
 
開發者ID:JackChan1999,項目名稱:letv,代碼行數:9,代碼來源:LoadingLayout.java

示例7: createButtonBackgroundTintColors

import android.content.res.ColorStateList; //導入依賴的package包/類
/**
 * Creates a new instance of ColorStateList as tint list for background of Button widget.
 *
 * @param context   Context used to resolve theme attributes that can be used to create the
 *                  requested tint list.
 * @param tintColor Color to be used as primary tint (accent) color.
 * @return New instance of ColorStateList specific for background of Button widget.
 */
@Nullable
static ColorStateList createButtonBackgroundTintColors(@NonNull Context context, int tintColor) {
	final int colorPressed = Colors.darker(tintColor, 0.1f);
	return tintColor != Color.TRANSPARENT ? new ColorStateList(
			new int[][]{
					// Enabled states ----------------------------------------------------------
					WidgetStateSet.ENABLED_PRESSED,
					WidgetStateSet.ENABLED_FOCUSED,
					WidgetStateSet.ENABLED,
					// Disabled states ---------------------------------------------------------
					WidgetStateSet.DISABLED
			},
			new int[]{
					// Enabled state colors ----------------------------------------------------
					colorPressed,
					colorPressed,
					tintColor,
					// Disabled state colors ---------------------------------------------------
					COLOR_DISABLED_BUTTON
			}
	) : null;
}
 
開發者ID:universum-studios,項目名稱:android_ui,代碼行數:31,代碼來源:TintManager.java

示例8: setTint

import android.content.res.ColorStateList; //導入依賴的package包/類
public static void setTint(@NonNull SeekBar seekBar, @ColorInt int color, boolean useDarker) {
    final ColorStateList s1 = getDisabledColorStateList(color,
            ContextCompat.getColor(seekBar.getContext(), useDarker ? R.color.ate_control_disabled_dark : R.color.ate_control_disabled_light));
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        seekBar.setThumbTintList(s1);
        seekBar.setProgressTintList(s1);
    } else if (Build.VERSION.SDK_INT > Build.VERSION_CODES.GINGERBREAD_MR1) {
        Drawable progressDrawable = createTintedDrawable(seekBar.getProgressDrawable(), s1);
        seekBar.setProgressDrawable(progressDrawable);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
            Drawable thumbDrawable = createTintedDrawable(seekBar.getThumb(), s1);
            seekBar.setThumb(thumbDrawable);
        }
    } else {
        PorterDuff.Mode mode = PorterDuff.Mode.SRC_IN;
        if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.GINGERBREAD_MR1) {
            mode = PorterDuff.Mode.MULTIPLY;
        }
        if (seekBar.getIndeterminateDrawable() != null)
            seekBar.getIndeterminateDrawable().setColorFilter(color, mode);
        if (seekBar.getProgressDrawable() != null)
            seekBar.getProgressDrawable().setColorFilter(color, mode);
    }
}
 
開發者ID:RajneeshSingh007,項目名稱:MusicX-music-player,代碼行數:25,代碼來源:TintHelper.java

示例9: tint

import android.content.res.ColorStateList; //導入依賴的package包/類
/**
 * Tint the {@link SeekBar}
 *
 * @param seekBar the seekbar
 * @param color   the color
 */
public static void tint(@NonNull SeekBar seekBar, @ColorInt int color) {
    ColorStateList s1 = ColorStateList.valueOf(color);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        seekBar.setThumbTintList(s1);
        seekBar.setProgressTintList(s1);
    } else if (Build.VERSION.SDK_INT > Build.VERSION_CODES.GINGERBREAD_MR1) {
        Drawable progressDrawable = DrawableCompat.wrap(seekBar.getProgressDrawable());
        seekBar.setProgressDrawable(progressDrawable);
        DrawableCompat.setTintList(progressDrawable, s1);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
            Drawable thumbDrawable = DrawableCompat.wrap(seekBar.getThumb());
            DrawableCompat.setTintList(thumbDrawable, s1);
            seekBar.setThumb(thumbDrawable);
        }
    } else {
        PorterDuff.Mode mode = PorterDuff.Mode.SRC_IN;
        if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.GINGERBREAD_MR1) {
            mode = PorterDuff.Mode.MULTIPLY;
        }
        if (seekBar.getIndeterminateDrawable() != null)
            seekBar.getIndeterminateDrawable().setColorFilter(color, mode);
        if (seekBar.getProgressDrawable() != null)
            seekBar.getProgressDrawable().setColorFilter(color, mode);
    }
}
 
開發者ID:jumaallan,項目名稱:AndelaTrackChallenge,代碼行數:32,代碼來源:Easel.java

示例10: startTimer

import android.content.res.ColorStateList; //導入依賴的package包/類
public void startTimer(){
    if(!isBegin){
        isBegin = true;
        timerview.setBackground(getResources().getDrawable(R.drawable.shape_bo_grey_cccccc_r4dp));
        timerview.setTextColor(ColorStateList.valueOf(ContextCompat.getColor(getContext(),R.color.grey_cccccc)));
        new CountDownTimer(60000, 1000) {
            @Override
            public void onTick(long millisUntilFinished) {
                timerview.setText(millisUntilFinished/1000 + "s");
            }

            @Override
            public void onFinish() {
                timerview.setBackground(getResources().getDrawable(R.drawable.shape_bo_white_r4dp));
                timerview.setTextColor(ColorStateList.valueOf(ContextCompat.getColor(getContext(),R.color.white)));
                timerview.setText("獲取驗證碼");
                isBegin = false;
            }
        }.start();
    }
}
 
開發者ID:Longalei,項目名稱:Edu,代碼行數:22,代碼來源:TimerView.java

示例11: 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

示例12: initializeWidget

import android.content.res.ColorStateList; //導入依賴的package包/類
/**
 * Initialize widget.
 */
private void initializeWidget() {
    int navigationColor = mWidget.getNavigationBarColor();
    navigationColor = AlbumUtils.getAlphaColor(navigationColor, mNavigationAlpha);
    StatusUtils.setFullToNavigationBar(this);
    StatusUtils.setNavigationBarColor(this, navigationColor);

    setTitle(mWidget.getTitle());

    if (!mCheckable) {
        findViewById(R.id.bottom_root).setVisibility(View.GONE);
    } else {
        ColorStateList itemSelector = mWidget.getMediaItemCheckSelector();
        mCheckBox.setSupportButtonTintList(itemSelector);

        mCheckBox.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                boolean isChecked = mCheckBox.isChecked();
                mCheckedMap.put(mAlbumFiles.get(mCurrentItemPosition), isChecked);
                setCheckedCountUI(getCheckCount());
            }
        });
    }
}
 
開發者ID:WeiXinqiao,項目名稱:Recognize-it,代碼行數:28,代碼來源:GalleryAlbumActivity.java

示例13: createTintedDrawable

import android.content.res.ColorStateList; //導入依賴的package包/類
@CheckResult
@Nullable
public static Drawable createTintedDrawable(@Nullable Drawable drawable, @NonNull ColorStateList sl) {
    if (drawable == null) return null;
    drawable = DrawableCompat.wrap(drawable.mutate());
    DrawableCompat.setTintList(drawable, sl);
    return drawable;
}
 
開發者ID:RajneeshSingh007,項目名稱:MusicX-music-player,代碼行數:9,代碼來源:TintHelper.java

示例14: applySimpleProgressTint

import android.content.res.ColorStateList; //導入依賴的package包/類
/**
 * Applies current first valid tint from {@link Decorator#mTintInfo} to the progress drawable as
 * whole.
 *
 * @see #applyProgressTints()
 */
private void applySimpleProgressTint() {
	if (mProgressDrawable instanceof TintDrawable) {
		final ProgressTintInfo tintInfo = mDecorator.getTintInfo();
		final TintDrawable tintDrawable = (TintDrawable) mProgressDrawable;
		boolean hasTintList, hasTintMode;
		hasTintList = hasTintMode = false;
		ColorStateList tintList = null;
		PorterDuff.Mode tintMode = null;
		if (tintInfo.hasTintList || tintInfo.hasTintMode) {
			hasTintList = tintInfo.hasTintList;
			tintList = tintInfo.tintList;
			hasTintMode = tintInfo.hasTintMode;
			tintMode = tintInfo.tintMode;
		} else if (tintInfo.hasSecondaryProgressTintList || tintInfo.hasSecondaryProgressTintMode) {
			hasTintList = tintInfo.hasSecondaryProgressTintList;
			tintList = tintInfo.secondaryProgressTintList;
			hasTintMode = tintInfo.hasSecondaryProgressTintMode;
			tintMode = tintInfo.secondaryProgressTintMode;
		} else if (tintInfo.hasProgressBackgroundTintList || tintInfo.hasProgressBackgroundTintMode) {
			hasTintList = tintInfo.hasProgressBackgroundTintList;
			tintList = tintInfo.progressBackgroundTintList;
			hasTintMode = tintInfo.hasProgressBackgroundTintMode;
			tintMode = tintInfo.progressBackgroundTintMode;
		}
		if (hasTintList) tintDrawable.setTintList(tintList);
		if (hasTintMode) tintDrawable.setTintMode(tintMode);
		if (mProgressDrawable.isStateful()) {
			mProgressDrawable.setState(getDrawableState());
		}
	}
}
 
開發者ID:universum-studios,項目名稱:android_ui,代碼行數:38,代碼來源:ProgressBarWidget.java

示例15: getBackgroundTintList

import android.content.res.ColorStateList; //導入依賴的package包/類
/**
 */
@Nullable
@Override
public ColorStateList getBackgroundTintList() {
	this.ensureDecorator();
	return mDecorator.getBackgroundTintList();
}
 
開發者ID:universum-studios,項目名稱:android_ui,代碼行數:9,代碼來源:GridViewWidget.java


注:本文中的android.content.res.ColorStateList類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。