当前位置: 首页>>代码示例>>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;未经允许,请勿转载。