List of usage examples for android.content.res ColorStateList valueOf
@NonNull public static ColorStateList valueOf(@ColorInt int color)
From source file:gov.wa.wsdot.android.wsdot.ui.trafficmap.TrafficMapActivity.java
private void toggleFabOff(FloatingActionButton fab) { fab.setBackgroundTintList(ColorStateList.valueOf(ContextCompat.getColor(this, R.color.semi_white))); fab.setImageDrawable(ContextCompat.getDrawable(this, R.drawable.ic_off)); }
From source file:org.gateshipone.malp.application.views.NowPlayingView.java
/** * Set the viewswitcher of cover/playlist view to the requested state. */* w ww. ja va2 s. c o m*/ * @param view the view which should be displayed. */ public void setViewSwitcherStatus(NowPlayingDragStatusReceiver.VIEW_SWITCHER_STATUS view) { int color = 0; switch (view) { case COVER_VIEW: // change the view only if the requested view is not displayed mViewSwitcher.setDisplayedChild(0); color = ThemeUtils.getThemeColor(getContext(), android.R.attr.textColor); break; case PLAYLIST_VIEW: // change the view only if the requested view is not displayed mViewSwitcher.setDisplayedChild(1); color = ThemeUtils.getThemeColor(getContext(), R.attr.colorAccent); break; } // tint the button according to the requested view mTopPlaylistButton.setImageTintList(ColorStateList.valueOf(color)); }
From source file:com.albedinsky.android.ui.widget.SeekBarWidget.java
/** * Sets a single color for the discrete indicator's text. * * @param color The desired color./* ww w. ja va2 s . c om*/ * @see #setDiscreteIndicatorTextColor(ColorStateList) */ public void setDiscreteIndicatorTextColor(@ColorInt int color) { setDiscreteIndicatorTextColor(ColorStateList.valueOf(color)); }
From source file:com.android.contacts.common.list.ContactListItemView.java
/** * Set drawable resources directly for the drawable resource of the photo view. * * @param drawableId Id of drawable resource. *///from w w w .j a va 2s.c o m public void setDrawableResource(int drawableId) { ImageView photo = getPhotoView(); photo.setScaleType(ImageView.ScaleType.CENTER); final Drawable drawable = ContextCompat.getDrawable(getContext(), drawableId); final int iconColor = ContextCompat.getColor(getContext(), R.color.search_shortcut_icon_color); if (CompatUtils.isLollipopCompatible()) { photo.setImageDrawable(drawable); photo.setImageTintList(ColorStateList.valueOf(iconColor)); } else { final Drawable drawableWrapper = DrawableCompat.wrap(drawable).mutate(); DrawableCompat.setTint(drawableWrapper, iconColor); photo.setImageDrawable(drawableWrapper); } }
From source file:com.mobileglobe.android.customdialer.common.list.ContactListItemView.java
/** * Set drawable resources directly for the drawable resource of the photo view. * * @param drawableId Id of drawable resource. *///w w w .j a va2 s . c o m public void setDrawableResource(int drawableId) { ImageView photo = getPhotoView(); photo.setScaleType(ScaleType.CENTER); final Drawable drawable = ContextCompat.getDrawable(getContext(), drawableId); final int iconColor = ContextCompat.getColor(getContext(), R.color.search_shortcut_icon_color); if (CompatUtils.isLollipopCompatible()) { photo.setImageDrawable(drawable); photo.setImageTintList(ColorStateList.valueOf(iconColor)); } else { final Drawable drawableWrapper = DrawableCompat.wrap(drawable).mutate(); DrawableCompat.setTint(drawableWrapper, iconColor); photo.setImageDrawable(drawableWrapper); } }