List of usage examples for android.support.v4.graphics.drawable DrawableCompat setTint
public static void setTint(Drawable drawable, int i)
From source file:com.tr4android.support.extension.internal.AccountAdapter.java
private static void setupCheckBox(CheckBox checkBox) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { checkBox.setButtonDrawable(R.drawable.btn_checkbox_circle); checkBox.setBackgroundResource(R.drawable.btn_checkbox_circle_background); } else {/*w w w . j a va 2 s. co m*/ Context context = checkBox.getContext(); AppCompatDrawableManager dm = AppCompatDrawableManager.get(); StateListDrawable button = new StateListDrawable(); button.addState(new int[] { android.R.attr.state_checked }, dm.getDrawable(context, R.drawable.ic_checkbox_circle_checked)); button.addState(new int[] {}, dm.getDrawable(context, R.drawable.ic_checkbox_circle_unchecked)); ColorStateList buttonTint = new ColorStateList(new int[][] { // states new int[] { android.R.attr.state_checked }, new int[] {} // state_default }, new int[] { // colors ThemeUtils.getThemeAttrColor(context, R.attr.colorControlActivated), ThemeUtils.getThemeAttrColor(context, R.attr.colorControlNormal) }); Drawable buttonCompat = DrawableCompat.wrap(button); DrawableCompat.setTintList(buttonCompat, buttonTint); checkBox.setButtonDrawable(buttonCompat); ShapeDrawable background = new ShapeDrawable(new OvalShape()); int backgroundTint = ThemeUtils.getThemeAttrColor(context, android.R.attr.colorBackground); Drawable backgroundCompat = DrawableCompat.wrap(background); DrawableCompat.setTint(backgroundCompat, backgroundTint); ViewCompatUtils.setBackground(checkBox, backgroundCompat); } }
From source file:org.gateshipone.malp.application.fragments.serverfragments.PlaylistTracksFragment.java
/** * Initialize the options menu.// ww w. ja v a 2 s .c o m * Be sure to call {@link #setHasOptionsMenu} before. * * @param menu The container for the custom options menu. * @param menuInflater The inflater to instantiate the layout. */ @Override public void onCreateOptionsMenu(Menu menu, MenuInflater menuInflater) { // Inflate the menu; this adds items to the action bar if it is present. menuInflater.inflate(R.menu.fragment_playlist_tracks, menu); // get tint color int tintColor = ThemeUtils.getThemeColor(getContext(), R.attr.malp_color_text_accent); Drawable drawable = menu.findItem(R.id.action_add_playlist).getIcon(); drawable = DrawableCompat.wrap(drawable); DrawableCompat.setTint(drawable, tintColor); menu.findItem(R.id.action_add_playlist).setIcon(drawable); drawable = menu.findItem(R.id.action_search).getIcon(); drawable = DrawableCompat.wrap(drawable); DrawableCompat.setTint(drawable, tintColor); menu.findItem(R.id.action_search).setIcon(drawable); SearchView searchView = (SearchView) menu.findItem(R.id.action_search).getActionView(); searchView.setOnQueryTextListener(new SearchTextObserver()); super.onCreateOptionsMenu(menu, menuInflater); }
From source file:com.finchuk.clock2.timepickers.Utils.java
public static void setTint(Drawable drawable, @ColorInt int color) { drawable = DrawableCompat.wrap(drawable.mutate()); DrawableCompat.setTint(drawable, color); }
From source file:com.joeyturczak.jtscanner.utils.Utility.java
public static void tintMenuIcon(Context context, MenuItem menuItem, int color) { Drawable drawable = menuItem.getIcon(); drawable = DrawableCompat.wrap(drawable); DrawableCompat.setTint(drawable, ContextCompat.getColor(context, color)); menuItem.setIcon(drawable);/*from w w w .j a v a2 s . co m*/ }
From source file:com.franmontiel.fullscreendialog.FullScreenDialogFragment.java
private void tintToolbarHomeButton(Toolbar toolbar, Drawable homeButtonDrawable) { int[] colorAttrs = new int[] { R.attr.colorControlNormal }; TypedArray a = toolbar.getContext().obtainStyledAttributes(colorAttrs); int color = a.getColor(0, -1); a.recycle();//w w w. j a v a 2 s . co m DrawableCompat.setTint(DrawableCompat.wrap(homeButtonDrawable), color); }
From source file:com.l4digital.fastscroll.FastScroller.java
/** * Set the background color of the index bubble. * * @param color The background color for the index bubble *//*from w w w .j a v a2 s . c o m*/ public void setBubbleColor(@ColorInt int color) { mBubbleColor = color; if (mBubbleImage == null) { mBubbleImage = DrawableCompat .wrap(ContextCompat.getDrawable(getContext(), R.drawable.fastscroll_bubble)); mBubbleImage.mutate(); } DrawableCompat.setTint(mBubbleImage, mBubbleColor); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { mBubbleView.setBackground(mBubbleImage); } else { //noinspection deprecation mBubbleView.setBackgroundDrawable(mBubbleImage); } }
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();// w w w . ja v a 2 s . c om } 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.joeyturczak.jtscanner.utils.Utility.java
public static Drawable tintDrawable(Context context, int id, int color) { Drawable drawable = context.getResources().getDrawable(id); if (drawable != null) { drawable = DrawableCompat.wrap(drawable); DrawableCompat.setTint(drawable, ContextCompat.getColor(context, color)); }/*from w ww . j a v a2 s . c o m*/ return drawable; }
From source file:com.owncloud.android.ui.activity.UserInfoActivity.java
private void populateUserInfoElement(View container, TextView textView, String text, ImageView icon, @ColorInt int tint) { if (!TextUtils.isEmpty(text)) { textView.setText(text);// w w w . ja v a 2 s .co m DrawableCompat.setTint(icon.getDrawable(), tint); } else { container.setVisibility(View.GONE); } }
From source file:org.gateshipone.malp.application.listviewitems.FileListItem.java
/** * Derived constructor to increase speed by directly selecting the right methods for the need of the using adapter. * * Generic Track Item constructor/* ww w. jav a2s. c o m*/ * * @param context Context used for creation of View * @param file Track that is used for this view * @param showIcon If left file/dir icon should be shown. It is not changeable after creation. */ public FileListItem(Context context, MPDTrack file, boolean showIcon) { this(context, showIcon); setTrack(file, context); if (showIcon) { Drawable icon = context.getDrawable(R.drawable.ic_file_48dp); if (icon != null) { // get tint color int tintColor = ThemeUtils.getThemeColor(context, android.R.attr.textColor); // tint the icon DrawableCompat.setTint(icon, tintColor); } mItemIcon.setImageDrawable(icon); } }