List of usage examples for android.support.v4.graphics.drawable DrawableCompat setTintList
public static void setTintList(Drawable drawable, ColorStateList colorStateList)
From source file:android.support.design.internal.BottomNavigationItemView.java
@Override public void setIcon(Drawable icon) { if (icon != null) { Drawable.ConstantState state = icon.getConstantState(); icon = DrawableCompat.wrap(state == null ? icon : state.newDrawable()).mutate(); DrawableCompat.setTintList(icon, mIconTint); }//from ww w. ja v a2 s. co m mIcon.setImageDrawable(icon); }
From source file:despotoski.nikola.github.com.bottomnavigationlayout.BottomNavigationTextView.java
@Override public void setSelected(boolean selected) { super.setSelected(selected); boolean isAlwaysTextShown = mAlwaysShowText || ((ViewGroup) getParent()).getChildCount() == 3; if (selected && !previouslySelected) { if (!isAlwaysTextShown) { animateSelection(0, ACTIVE_TEXT_SIZE); applyColorFilters();/* ww w. j a va2 s . c o m*/ } else { animateSelection(INACTIVE_TEXT_SIZE, ACTIVE_TEXT_SIZE); applyColorFilters(); } } else if (!selected && previouslySelected) { if (!isAlwaysTextShown) { animateSelection(ACTIVE_TEXT_SIZE, 0); applyColorFilters(); } else { animateSelection(ACTIVE_TEXT_SIZE, INACTIVE_TEXT_SIZE); applyColorFilters(); } } previouslySelected = selected; if (selected) { DrawableCompat.setTint(mTopDrawable, mTextActiveColorFilter); } else { DrawableCompat.setTintList(mTopDrawable, ColorStateList.valueOf(mInactiveTextColor)); } }
From source file:com.finchuk.clock2.timepickers.Utils.java
/** * Returns a tinted drawable from the given drawable resource, if {@code tintList != null}. * Otherwise, no tint will be applied.//from w w w . j a v a 2 s . c om */ public static Drawable getTintedDrawable(@NonNull Context context, @DrawableRes int drawableRes, @Nullable ColorStateList tintList) { Drawable d = DrawableCompat.wrap(ContextCompat.getDrawable(context, drawableRes).mutate()); DrawableCompat.setTintList(d, tintList); return d; }
From source file:com.ruesga.rview.drawer.DrawerNavigationMenuItemView.java
@Override public void setIcon(Drawable icon) { if (icon != null) { if (mShouldTintedIcon && mHasIconTintList) { Drawable.ConstantState state = icon.getConstantState(); icon = DrawableCompat.wrap(state == null ? icon : state.newDrawable()).mutate(); DrawableCompat.setTintList(icon, mIconTintList); }//w ww . j a v a 2 s . c o m icon.setBounds(0, 0, mIconSize, mIconSize); } else if (mNeedsEmptyIcon) { if (mEmptyDrawable == null) { mEmptyDrawable = ResourcesCompat.getDrawable(getResources(), R.drawable.navigation_empty_icon, getContext().getTheme()); if (mEmptyDrawable != null) { mEmptyDrawable.setBounds(0, 0, mIconSize, mIconSize); } } icon = mEmptyDrawable; } mIcon.setImageDrawable(icon); }
From source file:com.murati.oszk.audiobook.ui.MediaItemViewHolder.java
public static Drawable getDrawableByState(Context context, int state) { if (sColorStateNotPlaying == null || sColorStatePlaying == null) { initializeColorStateLists(context); }/*from ww w . j av a2 s. co m*/ switch (state) { case STATE_PLAYABLE: Drawable pauseDrawable = ContextCompat.getDrawable(context, R.drawable.ic_play_arrow_black_36dp); DrawableCompat.setTintList(pauseDrawable, sColorStateNotPlaying); return pauseDrawable; case STATE_PLAYING: AnimationDrawable animation = (AnimationDrawable) ContextCompat.getDrawable(context, R.drawable.ic_equalizer_white_36dp); DrawableCompat.setTintList(animation, sColorStatePlaying); animation.start(); return animation; case STATE_PAUSED: Drawable playDrawable = ContextCompat.getDrawable(context, R.drawable.ic_equalizer1_white_36dp); DrawableCompat.setTintList(playDrawable, sColorStatePlaying); return playDrawable; case STATE_NONE: default: return null; } }
From source file:despotoski.nikola.github.com.bottomnavigationlayout.BottomNavigationTextView.java
private void applyColorFilters() { if (isSelected()) { DrawableCompat.setTint(mTopDrawable, mTextActiveColorFilter); setTextColor(mTextActiveColorFilter); } else {/* w w w . j a v a 2 s . c o m*/ DrawableCompat.setTintList(mTopDrawable, ColorStateList.valueOf(mInactiveTextColor)); if (!mShiftingMode) { setTextColor(mInactiveTextColor); } } }
From source file:com.owncloud.android.utils.ThemeUtils.java
public static void tintSwitch(SwitchCompat switchView, int color, boolean colorText) { if (colorText) { switchView.setTextColor(color);/*w w w.j ava 2 s . com*/ } int trackColor = Color.argb(77, Color.red(color), Color.green(color), Color.blue(color)); // setting the thumb color DrawableCompat.setTintList(switchView.getThumbDrawable(), new ColorStateList(new int[][] { new int[] { android.R.attr.state_checked }, new int[] {} }, new int[] { color, Color.WHITE })); // setting the track color DrawableCompat.setTintList(switchView.getTrackDrawable(), new ColorStateList(new int[][] { new int[] { android.R.attr.state_checked }, new int[] {} }, new int[] { trackColor, Color.parseColor("#4D000000") })); }
From source file:com.amaze.filemanager.utils.Futils.java
public void setTint(CheckBox box, int color) { if (Build.VERSION.SDK_INT >= 21) return;//from w w w. ja v a 2 s . c o m ColorStateList sl = new ColorStateList( new int[][] { new int[] { -android.R.attr.state_checked }, new int[] { android.R.attr.state_checked } }, new int[] { Color.parseColor("#666666"), color }); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { box.setButtonTintList(sl); } else { Drawable drawable = DrawableCompat .wrap(ContextCompat.getDrawable(box.getContext(), R.drawable.abc_btn_check_material)); DrawableCompat.setTintList(drawable, sl); box.setButtonDrawable(drawable); } }
From source file:com.stfalcon.chatkit.messages.MessagesListStyle.java
Drawable getMessageSelector(@ColorInt int normalColor, @ColorInt int selectedColor, @ColorInt int pressedColor, @DrawableRes int shape) { Drawable button = DrawableCompat.wrap(getVectorDrawable(shape)); DrawableCompat .setTintList(button,/* ww w . ja v a2s .c om*/ new ColorStateList( new int[][] { new int[] { android.R.attr.state_selected }, new int[] { android.R.attr.state_pressed }, new int[] { -android.R.attr.state_pressed, -android.R.attr.state_selected } }, new int[] { selectedColor, pressedColor, normalColor })); return button; }
From source file:com.freshdigitable.udonroad.StatusDetailFragment.java
private void setTintList(Drawable drawable, @ColorRes int color) { DrawableCompat.setTintList(drawable, ContextCompat.getColorStateList(getContext(), color)); }