List of usage examples for android.support.v4.graphics.drawable DrawableCompat setTint
public static void setTint(Drawable drawable, int i)
From source file:com.justplay1.shoppist.utils.ViewUtils.java
public static Drawable getTinted(Drawable icon, @ColorInt int color) { if (icon == null) return null; icon = DrawableCompat.wrap(icon);/*from w w w .jav a 2 s . co m*/ DrawableCompat.setTint(icon, color); return icon; }
From source file:org.odk.collect.android.adapters.SortDialogAdapter.java
@Override public void onBindViewHolder(ViewHolder viewHolder, int position) { viewHolder.txtViewTitle.setText(sortList[position]); viewHolder.imgViewIcon/* w w w. j a va2 s . co m*/ .setImageResource(ApplicationConstants.getSortLabelToIconMap().get(sortList[position])); viewHolder.imgViewIcon.setImageDrawable(DrawableCompat.wrap(viewHolder.imgViewIcon.getDrawable())); if (position == selectedSortingOrder) { viewHolder.txtViewTitle.setTextColor(context.getResources().getColor(R.color.tintColor)); DrawableCompat.setTint(viewHolder.imgViewIcon.getDrawable(), context.getResources().getColor(R.color.tintColor)); } else { viewHolder.txtViewTitle.setTextColor(context.getResources().getColor(R.color.black)); DrawableCompat.setTintList(viewHolder.imgViewIcon.getDrawable(), null); } }
From source file:com.nerderylabs.android.nerdalert.ui.adapter.RecyclerViewAdapter.java
@Override public void onBindViewHolder(RecyclerViewAdapter.ViewHolder holder, int position) { Neighbor neighbor = neighbors.get(position); if (neighbor.getName() != null) { holder.name.setText(neighbor.getName()); }// w w w. j a v a 2 s . c o m if (neighbor.getTagline() != null) { holder.tagline.setText(neighbor.getTagline()); } if (neighbor.getBitmap() != null) { holder.photo.setImageDrawable(new BitmapDrawable(context.getResources(), neighbor.getBitmap())); } else { Drawable photo = ContextCompat.getDrawable(context, tab.getEmptyPhotoDrawableId()); DrawableCompat.setTint(photo, ContextCompat.getColor(context, R.color.color_nametag)); holder.photo.setImageDrawable(photo); } }
From source file:de.grobox.transportr.ui.BasePopupMenu.java
protected void showIcons() { // very ugly hack to show icons in PopupMenu // see: http://stackoverflow.com/a/18431605 try {/*w w w .j a v a2s . c om*/ Field[] fields = BasePopupMenu.class.getSuperclass().getDeclaredFields(); for (Field field : fields) { if ("mPopup".equals(field.getName())) { field.setAccessible(true); Object menuPopupHelper = field.get(this); Class<?> classPopupHelper = Class.forName(menuPopupHelper.getClass().getName()); Method setForceIcons = classPopupHelper.getMethod("setForceShowIcon", boolean.class); setForceIcons.invoke(menuPopupHelper, true); break; } } } catch (Exception e) { e.printStackTrace(); } // colorize icons according to theme for (int i = 0; i < getMenu().size(); i++) { DrawableCompat.setTint(getMenu().getItem(i).getIcon().mutate(), iconColor); } }
From source file:com.ruesga.rview.misc.PicassoHelper.java
public static Drawable getDefaultAvatar(Context context, @ColorRes int color) { Drawable drawable = ContextCompat.getDrawable(context, R.drawable.ic_account_circle); DrawableCompat.setTint(drawable, ContextCompat.getColor(context, color)); return drawable; }
From source file:de.grobox.transportr.favorites.trips.FavoriteTripPopupMenu.java
private void setFavState(MenuItem item, boolean is_fav) { if (is_fav) { item.setTitle(R.string.action_unfav_trip); item.setIcon(R.drawable.ic_action_star_empty); DrawableCompat.setTint(item.getIcon(), iconColor); } else {//from w ww.j av a2 s . co m item.setTitle(R.string.action_fav_trip); item.setIcon(R.drawable.ic_action_star); DrawableCompat.setTint(item.getIcon(), iconColor); } }
From source file:cn.qingchengfit.widgets.AnimatedButton.java
private void init(Context context, AttributeSet attrs) { TintTypedArray a = TintTypedArray.obtainStyledAttributes(getContext(), attrs, R.styleable.AnimatedButton, 0, 0);/*www.ja va2 s. c o m*/ TintTypedArray b = TintTypedArray.obtainStyledAttributes(getContext(), attrs, mAttr, 0, 0); Resources r = context.getResources(); final AppCompatDrawableManager drawableManager = AppCompatDrawableManager.get(); final int idon = a.getResourceId(R.styleable.AnimatedButton_ab_drawable_on, -1); final int idoff = a.getResourceId(R.styleable.AnimatedButton_ab_drawable_off, -1); final int idbg = b.getResourceId(0, -1); if (idbg != -1) { setBackgroundDrawable(drawableManager.getDrawable(getContext(), idbg)); } else { setBackgroundResource(R.color.transparent); } if (CompatUtils.less21()) { // onDrawable = drawableManager.getDrawable(getContext(),R.drawable.ai_drawable_expand_less); // offDrawable = drawableManager.getDrawable(getContext(),R.drawable.ai_drawable_expand_more); } else { offDrawable = drawableManager.getDrawable(getContext(), idoff); onDrawable = drawableManager.getDrawable(getContext(), idon); } int color = a.getColor(R.styleable.AnimatedButton_ab_color, Color.BLACK); DrawableCompat.setTint(offDrawable, color); DrawableCompat.setTint(onDrawable, color); a.recycle(); b.recycle(); setScaleType(ScaleType.CENTER_INSIDE); // if (isLollipop()) { setImageDrawable(checked ? onDrawable : offDrawable); // } else { // setImageDrawable(checked ? onDrawable : offDrawable); // } }
From source file:me.selinali.tribbble.ui.shot.ShotDetailsView.java
public ShotDetailsView(Context context, AttributeSet attrs) { super(context, attrs); inflate(context, R.layout.shot_details_view, this); ButterKnife.bind(this); setBackgroundColor(color(R.color.lighterGray)); for (TextView v : new TextView[] { mLikesTextView, mViewsTextView, mBucketsTextView, mCommentsTextView }) { DrawableCompat.setTint(v.getCompoundDrawables()[0], color(R.color.textNormal)); }/*from w ww . j av a2 s. c o m*/ DrawableCompat.setTint(mLikesTextView.getCompoundDrawables()[0], color(R.color.textNormal)); DrawableCompat.setTint(mViewsTextView.getCompoundDrawables()[0], color(R.color.textNormal)); DrawableCompat.setTint(mBucketsTextView.getCompoundDrawables()[0], color(R.color.textNormal)); DrawableCompat.setTint(mCommentsTextView.getCompoundDrawables()[0], color(R.color.textNormal)); }
From source file:com.grarak.kerneladiutor.views.BorderCircleView.java
public BorderCircleView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); if (isClickable()) { setForeground(ViewUtils.getSelectableBackground(context)); }/*from w w w. j a v a 2s . c om*/ mCheck = ContextCompat.getDrawable(context, R.drawable.ic_done); DrawableCompat.setTint(mCheck, Color.WHITE); mPaint = new Paint(Paint.ANTI_ALIAS_FLAG); mPaint.setColor(ViewUtils.getThemeAccentColor(context)); mPaintBorder = new Paint(Paint.ANTI_ALIAS_FLAG); mPaintBorder.setColor(ViewUtils.getColorPrimaryColor(context)); mPaintBorder.setStrokeWidth((int) getResources().getDimension(R.dimen.circleview_border)); mPaintBorder.setStyle(Paint.Style.STROKE); setWillNotDraw(false); }
From source file:com.arlib.floatingsearchview.util.Util.java
public static void setIconColor(ImageView iconHolder, int color) { Drawable wrappedDrawable = DrawableCompat.wrap(iconHolder.getDrawable()); DrawableCompat.setTint(wrappedDrawable, color); iconHolder.setImageDrawable(wrappedDrawable); iconHolder.invalidate();// w ww. j a v a 2 s . c o m }