List of usage examples for android.content.res ColorStateList valueOf
@NonNull public static ColorStateList valueOf(@ColorInt int color)
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 ava2 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.tr4android.support.extension.widget.LabelView.java
@TargetApi(Build.VERSION_CODES.LOLLIPOP) private void initBackgroundLollipop() { RoundRectDrawable shapeDrawable = new RoundRectDrawable(mBackgroundColor, mCornerRadius); RippleDrawable rippleDrawable = new RippleDrawable(ColorStateList.valueOf(mRippleColor), shapeDrawable, null);/*from w w w .j a v a 2 s. c o m*/ setElevation(mElevation); ViewCompatUtils.setBackground(this, rippleDrawable); }
From source file:com.philliphsu.bottomsheetpickers.Utils.java
/** * Sets the color on the {@code view}'s {@code selectableItemBackground} or the * borderless variant, whichever was set as the background. * @param view the view that should have its highlight color changed *//*from w ww . j a v a 2 s. c om*/ public static void setColorControlHighlight(@NonNull View view, @ColorInt int color) { Drawable selectableItemBackground = view.getBackground(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && selectableItemBackground instanceof RippleDrawable) { ((RippleDrawable) selectableItemBackground).setColor(ColorStateList.valueOf(color)); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && Utils.isTv(view.getContext())) { ((RippleDrawable) selectableItemBackground).setRadius(72); } } else { // Draws the color (src) onto the background (dest) *in the same plane*. // That means the color is not overlapping (i.e. on a higher z-plane, covering) // the background. That would be done with SRC_OVER. // The DrawableCompat tinting APIs *could* be a viable alternative, if you // call setTintMode(). Previous attempts using those APIs failed without // the tint mode. However, those APIs have the overhead of mutating and wrapping // the drawable. selectableItemBackground.setColorFilter(color, PorterDuff.Mode.SRC_ATOP); } }
From source file:com.socialinfotech.tabbar.smart.SmartTabLayout.java
/** * Set the color used for styling the tab text. This will need to be called prior to calling * {@link #setViewPager(ViewPager)} otherwise it will not get set * * @param color to use for tab text/* www .j a va 2 s . c o m*/ */ public void setDefaultTabTextColor(int color) { mTabViewTextColors = ColorStateList.valueOf(color); }
From source file:com.mikepenz.iconics.IconicsDrawable.java
/** * Set the color of the drawable./*from w w w . jav a 2 s.c o m*/ * * @param color The color, usually from android.graphics.Color or 0xFF012345. * @return The current IconExtDrawable for chaining. */ public IconicsDrawable color(@ColorInt int color) { mIconColor = ColorStateList.valueOf(color); updateIconColor(); return this; }
From source file:despotoski.nikola.github.com.bottomnavigationlayout.BottomNavigationTextView.java
private void applyColorFilters() { if (isSelected()) { DrawableCompat.setTint(mTopDrawable, mTextActiveColorFilter); setTextColor(mTextActiveColorFilter); } else {//from ww w . j a va 2 s .co m DrawableCompat.setTintList(mTopDrawable, ColorStateList.valueOf(mInactiveTextColor)); if (!mShiftingMode) { setTextColor(mInactiveTextColor); } } }
From source file:org.huxizhijian.hhcomicviewer.ui.entry.ComicDetailsActivity.java
@Override public void onException(Throwable e) { e.printStackTrace();// ww w .ja va2s . co m if (CommonUtils.getAPNType(ComicDetailsActivity.this) == CommonUtils.NONEWTWORK) { runOnUiThread(new Runnable() { @Override public void run() { Toast.makeText(ComicDetailsActivity.this, Constants.NO_NETWORK, Toast.LENGTH_SHORT).show(); //??? if (mComic != null) { if (mComic.isMark() || mComic.isDownload()) { runOnUiThread(new Runnable() { @Override public void run() { updateViews(); } }); } } } }); } else { runOnUiThread(new Runnable() { @Override public void run() { mBinding.FABComicDetails.setBackgroundTintList( ColorStateList.valueOf(getResources().getColor(R.color.colorAccent))); Toast.makeText(ComicDetailsActivity.this, "?", Toast.LENGTH_SHORT).show(); } }); } }
From source file:com.handmark.pulltorefresh.library.internal.LoadingLayout.java
public void setSubTextColor(final int color) { setSubTextColor(ColorStateList.valueOf(color)); }
From source file:com.handmark.pulltorefresh.library.internal.LoadingLayout.java
public void setTextColor(final int color) { setTextColor(ColorStateList.valueOf(color)); }
From source file:org.mariotaku.twidere.util.ThemedLayoutInflaterFactory.java
private static void applyTintableBackgroundViewTint(TintableBackgroundView tintable, int accentColor, int noTintColor, int backgroundTintColor, boolean isColorTint) { if (tintable instanceof Button) { } else if (tintable instanceof EditText) { tintable.setSupportBackgroundTintList(ColorStateList.valueOf(backgroundTintColor)); } else if (isColorTint) { final int[][] states = { { android.R.attr.state_selected }, { android.R.attr.state_focused }, { android.R.attr.state_pressed }, { 0 } }; final int[] colors = { accentColor, accentColor, accentColor, noTintColor }; tintable.setSupportBackgroundTintList(new ColorStateList(states, colors)); } else {/*from w ww. j a v a 2 s . com*/ tintable.setSupportBackgroundTintList(ColorStateList.valueOf(accentColor)); } }