Java Code Examples for android.content.res.ColorStateList

The following are top voted examples for showing how to use android.content.res.ColorStateList. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: BilibiliClient   File: BangumiScheduleSection.java   View source code 6 votes vote down vote up
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);
}
 
Example 2
Project: MusicX-music-player   File: Playing4Fragment.java   View source code 6 votes vote down vote up
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));
    }

}
 
Example 3
Project: atlas   File: DelegateResources.java   View source code 6 votes vote down vote up
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();
    }
}
 
Example 4
Project: Depth   File: RippleHelper.java   View source code 6 votes vote down vote up
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
                    }
    );
}
 
Example 5
Project: BilibiliClient   File: VideoDetailsActivity.java   View source code 6 votes vote down vote up
@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()));
}
 
Example 6
Project: letv   File: LoadingLayout.java   View source code 6 votes vote down vote up
private void setTextColor(ColorStateList color) {
    if (this.mHeaderText != null) {
        this.mHeaderText.setTextColor(color);
    }
    if (this.mSubHeaderText != null) {
        this.mSubHeaderText.setTextColor(color);
    }
}
 
Example 7
Project: android_ui   File: TintManager.java   View source code 6 votes vote down vote up
/**
 * 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;
}
 
Example 8
Project: MusicX-music-player   File: TintHelper.java   View source code 6 votes vote down vote up
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);
    }
}
 
Example 9
Project: AndelaTrackChallenge   File: Easel.java   View source code 6 votes vote down vote up
/**
 * 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);
    }
}
 
Example 10
Project: Edu   File: TimerView.java   View source code 6 votes vote down vote up
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();
    }
}
 
Example 11
Project: NumberPadTimePicker   File: NumberPadTimePickerBottomSheetComponent.java   View source code 6 votes vote down vote up
@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;
}
 
Example 12
Project: Recognize-it   File: GalleryAlbumActivity.java   View source code 6 votes vote down vote up
/**
 * 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());
            }
        });
    }
}
 
Example 13
Project: MusicX-music-player   File: TintHelper.java   View source code 5 votes vote down vote up
@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;
}
 
Example 14
Project: android_ui   File: ProgressBarWidget.java   View source code 5 votes vote down vote up
/**
 * 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());
		}
	}
}
 
Example 15
Project: android_ui   File: GridViewWidget.java   View source code 5 votes vote down vote up
/**
 */
@Nullable
@Override
public ColorStateList getBackgroundTintList() {
	this.ensureDecorator();
	return mDecorator.getBackgroundTintList();
}
 
Example 16
Project: qmui   File: QMUILinkify.java   View source code 5 votes vote down vote up
/**
 * Scans the text of the provided TextView and turns all occurrences of
 * the link types indicated in the mask into clickable links.  If matches
 * are found the movement method for the TextView is set to
 * LinkMovementMethod.
 */
public static final boolean addLinks(TextView text, int mask, ColorStateList linkColor, ColorStateList bgColor, QMUIOnSpanClickListener l) {
    if (mask == 0) {
        return false;
    }

    CharSequence t = text.getText();

    if (t instanceof Spannable) {
        if (addLinks((Spannable) t, mask, linkColor, bgColor, l)) {
            addLinkMovementMethod(text);
            return true;
        }

        return false;
    } else {
        SpannableString s = SpannableString.valueOf(t);

        if (addLinks(s, mask, linkColor, bgColor, l)) {
            addLinkMovementMethod(text);
            text.setText(s);

            return true;
        }

        return false;
    }
}
 
Example 17
Project: AvatarView   File: RoundedImageView.java   View source code 5 votes vote down vote up
public RoundedImageView(Context context, AttributeSet attrs, int defStyle) {
	super(context, attrs, defStyle);

	TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.RoundedImageView, defStyle, 0);

	int index = a.getInt(R.styleable.RoundedImageView_android_scaleType, -1);
	if (index >= 0) {
		setScaleType(SCALE_TYPES[index]);
	} else {
		// default scaletype to FIT_CENTER
		setScaleType(ScaleType.FIT_CENTER);
	}

	cornerRadius = a.getDimensionPixelSize(R.styleable.RoundedImageView_rcorner_radius, -1);
	borderWidth = a.getDimensionPixelSize(R.styleable.RoundedImageView_rborder_width, -1);

	// don't allow negative values for radius and border
	if (cornerRadius < 0) {
		cornerRadius = DEFAULT_RADIUS;
	}
	if (borderWidth < 0) {
		borderWidth = DEFAULT_BORDER_WIDTH;
	}

	borderColor = a.getColorStateList(R.styleable.RoundedImageView_rborder_color);
	if (borderColor == null) {
		borderColor = ColorStateList.valueOf(RoundedDrawable.DEFAULT_BORDER_COLOR);
	}

	mutateBackground = a.getBoolean(R.styleable.RoundedImageView_rmutate_background, false);
	isOval = a.getBoolean(R.styleable.RoundedImageView_roval, false);

	updateDrawableAttrs();
	updateBackgroundDrawableAttrs(true);

	a.recycle();
}
 
Example 18
Project: ReadMark   File: SkinResource.java   View source code 5 votes vote down vote up
/**
 * 获取颜色
 * @param resName
 * @return
 */
public ColorStateList getColorByName(String resName){
    try{
        int resId = mSkinResources.getIdentifier(resName, "color", mPackageName);
        ColorStateList color = mSkinResources.getColorStateList(resId);
        return color;

    }catch (Exception e){
        e.printStackTrace();
        return null;
    }
}
 
Example 19
Project: android_ui   File: TextViewDecorator.java   View source code 5 votes vote down vote up
/**
 * Applies a tint to the compound drawables. Does not modify the current tint mode, which is
 * {@link PorterDuff.Mode#SRC_IN} by default.
 *
 * @param tint The desired tint to be applied. May be {@code null} to clear the current tint.
 */
public void setCompoundDrawableTintList(ColorStateList tint) {
	if (UiConfig.MATERIALIZED_MARSHMALLOW) {
		superSetCompoundDrawableTintList(tint);
		return;
	}
	final CompoundTintInfo tintInfo = getTintInfo();
	if (!tintInfo.hasCompoundTintMode) {
		tintInfo.compoundTintMode = PorterDuff.Mode.SRC_IN;
	}
	tintInfo.compoundTintList = tint;
	tintInfo.hasCompoundTintList = true;
	this.applyCompoundDrawablesTint();
}
 
Example 20
Project: BilibiliClient   File: VideoDetailsActivity.java   View source code 5 votes vote down vote up
@Override
public void loadData() {
    RetrofitHelper.getBiliAppAPI()
            .getVideoDetails(mAv)
            .compose(bindToLifecycle())
            .subscribeOn(Schedulers.io())
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe(videoDetailsInfo -> {
                mVideoDetailsInfo = videoDetailsInfo.getData();
                finishTask();
            }, throwable -> {
                mFAB.setClickable(false);
                mFAB.setBackgroundTintList(ColorStateList.valueOf(getResources().getColor(R.color.gray_20)));
            });
}
 
Example 21
Project: NeoTerm   File: PhoneRecyclerAdapter.java   View source code 5 votes vote down vote up
@Override
public final void onTabBackgroundColorChanged(@Nullable final ColorStateList colorStateList) {
    TabItemIterator iterator = new TabItemIterator.Builder(model, viewRecycler).create();
    TabItem tabItem;

    while ((tabItem = iterator.next()) != null) {
        if (tabItem.isInflated()) {
            adaptBackgroundColor(tabItem.getView(), tabItem.getViewHolder(), tabItem.getTab());
        }
    }
}
 
Example 22
Project: Recognize-it   File: Widget.java   View source code 5 votes vote down vote up
protected Widget(Parcel in) {
    //noinspection WrongConstant
    mStyle = in.readInt();
    mStatusBarColor = in.readInt();
    mToolBarColor = in.readInt();
    mNavigationBarColor = in.readInt();
    mTitle = in.readString();
    mMediaItemCheckSelector = in.readParcelable(ColorStateList.class.getClassLoader());
    mBucketItemCheckSelector = in.readParcelable(ColorStateList.class.getClassLoader());
    mButtonStyle = in.readParcelable(ButtonStyle.class.getClassLoader());
}
 
Example 23
Project: sao   File: CoolView.java   View source code 5 votes vote down vote up
private int[] getColorsFromColorStateList(ColorStateList colorStateList) {
    if (colorStateList == null) {
        return colors;
    }
    try {
        return (int[]) ColorStateList.class.getMethod("getColors").invoke(colorStateList);
    } catch (Exception e) {
        e.printStackTrace();
    }
    return colors;
}
 
Example 24
Project: SingleSelectBar   File: ResHelper.java   View source code 5 votes vote down vote up
private void updateTextColor() {
    int[] colors = new int[] {colorUnselected, colorSelected};
    int[][] states = new int[2][];
    states[0] = new int[] {android.R.attr.state_selected};
    states[1] = new int[] {};
    textColor = new ColorStateList(states, colors);
}
 
Example 25
Project: LiteReader   File: DoubanMovieMoreReviewViewModel.java   View source code 5 votes vote down vote up
@Override
public void initTab(TabLayout tabLayout) {
    tabLayout.setTabMode(TabLayout.MODE_FIXED);
    tabLayout.setTabGravity(TabLayout.GRAVITY_FILL);
    tabLayout.setBackgroundColor(getContext().getResources().getColor(R.color.colorPrimary));
    tabLayout.setSelectedTabIndicatorColor(Color.WHITE);
    tabLayout.setTabTextColors(ColorStateList.valueOf(Color.WHITE));
}
 
Example 26
Project: Android-skin-support   File: SkinCompatDrawableManager.java   View source code 5 votes vote down vote up
private static PorterDuffColorFilter createTintFilter(ColorStateList tint,
                                                      PorterDuff.Mode tintMode, final int[] state) {
    if (tint == null || tintMode == null) {
        return null;
    }
    final int color = tint.getColorForState(state, Color.TRANSPARENT);
    return getPorterDuffColorFilter(color, tintMode);
}
 
Example 27
Project: android_ui   File: TextAppearance.java   View source code 5 votes vote down vote up
/**
 * Sets a stateful set of colors for text.
 *
 * @param colors The desired colors. May be {@code null} to clear the current ones.
 * @return {@code True} if colors of this text appearance have changed, {@code false} otherwise.
 * @see #getTextColor()
 */
public boolean setTextColor(@Nullable ColorStateList colors) {
	if (mTextColors != colors) {
		this.mTextColors = colors;
		return true;
	}
	return false;
}
 
Example 28
Project: revolution-irc   File: ThemedSeekBar.java   View source code 5 votes vote down vote up
private static ColorStateList createSeekBarThumbColorList(Context ctx) {
    int accentColor = ThemeHelper.getAccentColor(ctx);
    int normalColor = StyledAttributesHelper.getColor(ctx, R.attr.colorControlNormal, 0);
    int disabledColor = ColorUtils.setAlphaComponent(normalColor, (int) (255.f *
            StyledAttributesHelper.getFloat(ctx, android.R.attr.disabledAlpha, 1.f)));
    return new ColorStateList(new int[][] {
            new int[] { -android.R.attr.state_enabled },
            new int[] { }
    }, new int[] {
            disabledColor,
            accentColor
    });
}
 
Example 29
Project: Aequorea   File: SettingsActivity.java   View source code 5 votes vote down vote up
private void colorCheckBox() {
    int titleColor = ThemeHelper.getResourceColor(this, R.attr.title_color);
    int accentColor = ThemeHelper.getResourceId(this, R.attr.colorAccent);
    int subTitleColor = ThemeHelper.getResourceColor(this, R.attr.subtitle_color);

    ColorStateList stateList = new ColorStateList(new int[][]{{ -android.R.attr.state_checked }, { android.R.attr.state_checked }},
        new int[]{0x8A000000, ContextCompat.getColor(this, accentColor)});

    for (ACheckBox cb : mList) {
        cb.setColorStateList(stateList);
        cb.setTextColor(titleColor, subTitleColor);
    }
}
 
Example 30
Project: boohee_v5.6   File: AppCompatDrawableManager.java   View source code 5 votes vote down vote up
private ColorStateList getTintListFromCache(@NonNull Context context, @DrawableRes int resId) {
    if (this.mTintLists == null) {
        return null;
    }
    SparseArray<ColorStateList> tints = (SparseArray) this.mTintLists.get(context);
    if (tints != null) {
        return (ColorStateList) tints.get(resId);
    }
    return null;
}
 
Example 31
Project: MakiLite   File: SnackBar.java   View source code 5 votes vote down vote up
/**
 * Sets the text color of the action specified in
 * {@link #setAction(CharSequence, View.OnClickListener)}.
 */
@NonNull
public SnackBar setActionTextColor(ColorStateList colors) {
    this.snackbar.setActionTextColor(colors);

    return this;
}
 
Example 32
Project: SetupWizardLibCompat   File: GlifLayout.java   View source code 5 votes vote down vote up
private void setProgressBarColor(ColorStateList color) {
    if (Build.VERSION.SDK_INT >= VERSION_CODES.LOLLIPOP) {
        final ProgressBar bar = peekProgressBar();
        if (bar != null) {
            bar.setIndeterminateTintList(color);
        }
    }
}
 
Example 33
Project: Android-skin-support   File: SkinMaterialTextInputLayout.java   View source code 5 votes vote down vote up
private void setDefaultTextColor(ColorStateList colors) {
    try {
        Field defaultTextColor = TextInputLayout.class.getDeclaredField("mDefaultTextColor");
        defaultTextColor.setAccessible(true);
        defaultTextColor.set(this, colors);
        updateLabelState();
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
Example 34
Project: SkinFramework   File: ComposedResources.java   View source code 5 votes vote down vote up
@RequiresApi(api = Build.VERSION_CODES.M)
@Nullable
@Override
public ColorStateList getColorStateList(@ColorRes int id, @Nullable Theme theme) throws NotFoundException {
    int realId = getCorrespondResId(id);
    if (realId > 0) {
        return mSkinResources.getColorStateList(realId, theme);
    }
    return super.getColorStateList(id, theme);
}
 
Example 35
Project: LaunchEnr   File: NotificationMainView.java   View source code 5 votes vote down vote up
@Override
protected void onFinishInflate() {
    super.onFinishInflate();

    mTextAndBackground = (ViewGroup) findViewById(R.id.text_and_background);
    ColorDrawable colorBackground = (ColorDrawable) mTextAndBackground.getBackground();
    mBackgroundColor = colorBackground.getColor();
    RippleDrawable rippleBackground = new RippleDrawable(ColorStateList.valueOf(
            ThemeUtils.getAttrColor(getContext(), android.R.attr.colorControlHighlight)),
            colorBackground, null);
    mTextAndBackground.setBackground(rippleBackground);
    mTitleView = (TextView) mTextAndBackground.findViewById(R.id.title);
    mTextView = (TextView) mTextAndBackground.findViewById(R.id.text);
}
 
Example 36
Project: FastLib   File: FastLoadMoreView.java   View source code 5 votes vote down vote up
private void initView(BaseViewHolder holder) {
    if (holder == null) {
        return;
    }

    holder.setText(R.id.tv_loadingFastLoadMore, mLoadingText)
            .setTextColor(R.id.tv_loadingFastLoadMore, mLoadingTextColor)
            .setText(R.id.tv_loadFailFastLoadMore, mLoadFailText)
            .setTextColor(R.id.tv_loadFailFastLoadMore, mLoadFailTextColor)
            .setText(R.id.tv_loadEndFastLoadMore, mLoadEndText)
            .setTextColor(R.id.tv_loadEndFastLoadMore, mLoadEndTextColor);
    TextView tvLoading = holder.getView(R.id.tv_loadingFastLoadMore);
    TextView tvLoadFail = holder.getView(R.id.tv_loadFailFastLoadMore);
    TextView tvLoadEnd = holder.getView(R.id.tv_loadEndFastLoadMore);
    ProgressBar pbLoading = holder.getView(R.id.pb_loadingFastLoadMore);
    tvLoading.setTextSize(TypedValue.COMPLEX_UNIT_PX, mLoadingTextSize);
    tvLoading.getPaint().setFakeBoldText(mLoadingTextFakeBold);
    tvLoadFail.setTextSize(TypedValue.COMPLEX_UNIT_PX, mLoadFailTextSize);
    tvLoadFail.getPaint().setFakeBoldText(mLoadFailTextFakeBold);
    tvLoadEnd.setTextSize(TypedValue.COMPLEX_UNIT_PX, mLoadEndTextSize);
    tvLoadEnd.getPaint().setFakeBoldText(mLoadEndTextFakeBold);
    if (mLoadingSize >= 0) {
        pbLoading.getIndeterminateDrawable().setBounds(0, 0, mLoadingSize, mLoadingSize);
        ViewGroup.LayoutParams params = pbLoading.getLayoutParams();
        params.width = mLoadingSize;
        params.height = mLoadingSize;
    }
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        pbLoading.setIndeterminateTintList(ColorStateList.valueOf(mLoadingProgressColor));
    }
    if (mLoadingProgressDrawable != null) {
        mLoadingProgressDrawable.setBounds(pbLoading.getIndeterminateDrawable().getBounds());
        pbLoading.setIndeterminateDrawable(mLoadingProgressDrawable);
    }
}
 
Example 37
Project: android_ui   File: SeekBarWidget.java   View source code 5 votes vote down vote up
/**
 * 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 SeekBarTintInfo tintInfo = mDecorator.getTintInfo();
		final TintDrawable tintDrawable = (TintDrawable) mProgressDrawable;
		boolean hasTintList, hasTintMode;
		hasTintList = hasTintMode = false;
		ColorStateList tintList = null;
		PorterDuff.Mode tintMode = null;
		if (tintInfo.hasPrimaryProgressTintList || tintInfo.hasPrimaryProgressTintMode) {
			hasTintList = tintInfo.hasPrimaryProgressTintList;
			tintList = tintInfo.primaryProgressTintList;
			hasTintMode = tintInfo.hasPrimaryProgressTintMode;
			tintMode = tintInfo.primaryProgressTintMode;
		} 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());
		}
	}
}
 
Example 38
Project: android-project-gallery   File: RoundedImageView.java   View source code 5 votes vote down vote up
public void setBorderColor(ColorStateList colors)
{
	if (borderColor.equals(colors))
	{
		return;
	}

	borderColor = (colors != null) ? colors : ColorStateList.valueOf(RoundedDrawable.DEFAULT_BORDER_COLOR);
	updateDrawableAttrs();
	updateBackgroundDrawableAttrs(false);
	if (borderWidth > 0)
	{
		invalidate();
	}
}
 
Example 39
Project: android_ui   File: ImageDecorator.java   View source code 5 votes vote down vote up
/**
 * Returns the tint applied to the image drawable.
 *
 * @return Image drawable's tint or {@code null} if no tint is applied.
 */
ColorStateList getImageTintList() {
	if (UiConfig.MATERIALIZED) {
		return superGetImageTintList();
	}
	return mTintInfo != null ? mTintInfo.tintList : null;
}
 
Example 40
Project: UIWidget   File: TitleBarView.java   View source code 5 votes vote down vote up
/**
 * 设置文字状态颜色-如按下颜色变化
 *
 * @param color
 * @return
 */
public TitleBarView setLeftTextColor(ColorStateList color) {
    try {
        mLeftTv.setTextColor(color);
    } catch (Exception e) {
    }
    return this;
}