Java Code Examples for android.support.v4.graphics.drawable.DrawableCompat#wrap()
The following examples show how to use
android.support.v4.graphics.drawable.DrawableCompat#wrap() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AppCompatCompoundDrawableHelper.java From timecat with Apache License 2.0 | 6 votes |
private Drawable applySupportCompoundDrawableTint(int position) { Drawable originDrawable = ((TextView) mView).getCompoundDrawables()[position]; Drawable compoundDrawable = originDrawable; TintInfo tintInfo = mCompoundDrawableTintInfos[position]; if (compoundDrawable != null && tintInfo != null && tintInfo.mHasTintList) { compoundDrawable = DrawableCompat.wrap(compoundDrawable); compoundDrawable.mutate(); if (tintInfo.mHasTintList) { DrawableCompat.setTintList(compoundDrawable, tintInfo.mTintList); } if (tintInfo.mHasTintMode) { DrawableCompat.setTintMode(compoundDrawable, tintInfo.mTintMode); } if (compoundDrawable.isStateful()) { compoundDrawable.setState(originDrawable.getState()); } return compoundDrawable; } return originDrawable; }
Example 2
Source File: AppCompatBackgroundHelper.java From timecat with Apache License 2.0 | 6 votes |
private boolean applySupportBackgroundTint() { Drawable backgroundDrawable = mView.getBackground(); if (backgroundDrawable != null && mBackgroundTintInfo != null && mBackgroundTintInfo.mHasTintList) { backgroundDrawable = DrawableCompat.wrap(backgroundDrawable); backgroundDrawable = backgroundDrawable.mutate(); if (mBackgroundTintInfo.mHasTintList) { DrawableCompat.setTintList(backgroundDrawable, mBackgroundTintInfo.mTintList); } if (mBackgroundTintInfo.mHasTintMode) { DrawableCompat.setTintMode(backgroundDrawable, mBackgroundTintInfo.mTintMode); } if (backgroundDrawable.isStateful()) { backgroundDrawable.setState(mView.getDrawableState()); } setBackgroundDrawable(backgroundDrawable); return true; } return false; }
Example 3
Source File: AppCompatSwitchHelper.java From timecat with Apache License 2.0 | 6 votes |
private boolean applySupportDrawableTint() { Drawable drawable = mDrawableCallback.getDrawable(); if (drawable != null && mTintInfo != null && mTintInfo.mHasTintList) { Drawable tintDrawable = drawable.mutate(); tintDrawable = DrawableCompat.wrap(tintDrawable); if (mTintInfo.mHasTintList) { DrawableCompat.setTintList(tintDrawable, mTintInfo.mTintList); } if (mTintInfo.mHasTintMode) { DrawableCompat.setTintMode(tintDrawable, mTintInfo.mTintMode); } if (tintDrawable.isStateful()) { tintDrawable.setState(mSwitchCompat.getDrawableState()); } setDrawable(tintDrawable); if (drawable == tintDrawable) { tintDrawable.invalidateSelf(); } return true; } return false; }
Example 4
Source File: EmTintUtils.java From AndroidTint with Apache License 2.0 | 6 votes |
public static void setTint(@NonNull CheckedTextView textView, @ColorInt int color) { ColorStateList sl = new ColorStateList(new int[][]{ new int[]{-android.R.attr.state_checked}, new int[]{android.R.attr.state_checked} }, new int[]{ ThemeHelper.resolveColor(textView.getContext(), R.attr.colorControlNormal), color }); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { textView.setCheckMarkTintList(sl); } else { Drawable d = DrawableCompat.wrap(ContextCompat.getDrawable(textView.getContext(), R.drawable.abc_btn_check_material)); DrawableCompat.setTintList(d, sl); textView.setCheckMarkDrawable(d); } }
Example 5
Source File: Slider.java From Nimingban with Apache License 2.0 | 5 votes |
@SuppressWarnings("deprecation") public BubbleView(Context context, Paint paint) { super(context); setImageResource(R.drawable.v_slider_bubble); mDrawable = DrawableCompat.wrap(getDrawable()); setImageDrawable(mDrawable); mTextPaint = paint; }
Example 6
Source File: DrawableUtils.java From PainlessMusicPlayer with Apache License 2.0 | 5 votes |
@Nullable public static Drawable getTintedDrawable(@Nullable Drawable drawable, @ColorInt final int tint) { if (drawable != null) { drawable = DrawableCompat.wrap(drawable); DrawableCompat.setTint(drawable, tint); } return drawable; }
Example 7
Source File: Util.java From RetroMusicPlayer with GNU General Public License v3.0 | 5 votes |
@CheckResult @Nullable public static Drawable createTintedDrawable(@Nullable Drawable drawable, @ColorInt int i) { if (drawable == null) { return null; } Drawable wrap = DrawableCompat.wrap(drawable.mutate()); DrawableCompat.setTintMode(wrap, Mode.SRC_IN); DrawableCompat.setTint(wrap, i); return wrap; }
Example 8
Source File: ThemeUtils.java From timecat with Apache License 2.0 | 5 votes |
public static Drawable tintDrawable(Drawable drawable, @ColorInt int color, PorterDuff.Mode mode) { if (drawable == null) return null; Drawable wrapper = DrawableCompat.wrap(drawable.mutate()); DrawableCompat.setTint(wrapper, color); DrawableCompat.setTintMode(drawable, mode); return wrapper; }
Example 9
Source File: MessageListStyle.java From aurora-imui with MIT License | 5 votes |
public Drawable getMessageSelector(@ColorInt int normalColor, @ColorInt int selectedColor, @ColorInt int pressedColor, @DrawableRes int shape) { Drawable button = DrawableCompat.wrap(getVectorDrawable(shape)); DrawableCompat.setTintList(button, 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; }
Example 10
Source File: FastScroller.java From APlayer with GNU General Public License v3.0 | 5 votes |
/** * Set the color of the scroll track. * * @param color The color for the scroll track */ public void setTrackColor(@ColorInt int color) { @ColorInt int trackColor = color; if (mTrackImage == null) { mTrackImage = DrawableCompat .wrap(ContextCompat.getDrawable(getContext(), R.drawable.fastscroll_track)); mTrackImage.mutate(); } DrawableCompat.setTint(mTrackImage, trackColor); mTrackView.setImageDrawable(mTrackImage); }
Example 11
Source File: DataSharingFragment.java From KernelAdiutor with GNU General Public License v3.0 | 5 votes |
@Override protected Drawable getBottomFabDrawable() { Drawable drawable = DrawableCompat.wrap( ContextCompat.getDrawable(getActivity(), R.drawable.ic_search)); DrawableCompat.setTint(drawable, Color.WHITE); return drawable; }
Example 12
Source File: ExpandedAlarmViewHolder.java From ClockPlus with GNU General Public License v3.0 | 5 votes |
private void bindRingtone() { int iconTint = Utils.getTextColorFromThemeAttr(getContext(), R.attr.themedIconTint); Drawable ringtoneIcon = mRingtone.getCompoundDrawablesRelative()[0/*start*/]; ringtoneIcon = DrawableCompat.wrap(ringtoneIcon.mutate()); DrawableCompat.setTint(ringtoneIcon, iconTint); mRingtone.setCompoundDrawablesRelativeWithIntrinsicBounds(ringtoneIcon, null, null, null); String title = RingtoneManager.getRingtone(getContext(), getSelectedRingtoneUri()).getTitle(getContext()); mRingtone.setText(title); }
Example 13
Source File: Utils.java From belvedere with Apache License 2.0 | 5 votes |
static void internalSetTint(ImageView imageView, int color) { if(imageView == null) { return; } Drawable d = DrawableCompat.wrap(imageView.getDrawable()); if(d != null) { DrawableCompat.setTint(d.mutate(), color); } imageView.invalidate(); }
Example 14
Source File: SublimeCheckboxItemView.java From SublimeNavigationView with Apache License 2.0 | 5 votes |
public void setCheckableItemTintList(ColorStateList checkableItemTintList) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { mCheckbox.setButtonTintList(checkableItemTintList); } else { Drawable dCheckbox = getResources().getDrawable(R.drawable.checkbox_pre_lollipop); if (dCheckbox != null) { dCheckbox = DrawableCompat.wrap(dCheckbox); DrawableCompat.setTintList(dCheckbox, checkableItemTintList); mCheckbox.setButtonDrawable(dCheckbox); } } }
Example 15
Source File: CustomCheckBox.java From KAM with GNU General Public License v3.0 | 5 votes |
private void updateTintColor() { //TODO: see here int[][] r1 = new int[2][]; r1[0] = new int[]{-16842912}; r1[1] = new int[]{16842912}; ColorStateList colorStateList = new ColorStateList(r1, new int[]{resolveColor(getContext(), R.attr.colorControlNormal, 0) , AppHelper.getAccentColor(getContext())}); if (Build.VERSION.SDK_INT >= 21) { setButtonTintList(colorStateList); return; } Drawable wrap = DrawableCompat.wrap(ContextCompat.getDrawable(getContext(), R.drawable.abc_btn_check_material)); DrawableCompat.setTintList(wrap, colorStateList); setButtonDrawable(wrap); }
Example 16
Source File: Tints.java From AndroidCommons with Apache License 2.0 | 4 votes |
private static Drawable tint(Drawable drawable, ColorStateList color) { Drawable wrapped = DrawableCompat.wrap(drawable); wrapped.mutate(); DrawableCompat.setTintList(wrapped, color); return wrapped; }
Example 17
Source File: BottomNavigationTab.java From JD-Test with Apache License 2.0 | 4 votes |
public void setInactiveIcon(Drawable icon) { mCompactInActiveIcon = DrawableCompat.wrap(icon); isInActiveIconSet = true; }
Example 18
Source File: IconTab.java From ResearchStack with Apache License 2.0 | 4 votes |
public void setIconTint(int iconTint) { Drawable drawable = icon.getDrawable(); drawable = DrawableCompat.wrap(drawable); DrawableCompat.setTint(drawable, iconTint); icon.setImageDrawable(drawable); }
Example 19
Source File: Util.java From floatingsearchview with Apache License 2.0 | 4 votes |
public static void setIconColor(ImageView iconHolder, int color) { Drawable wrappedDrawable = DrawableCompat.wrap(iconHolder.getDrawable()); DrawableCompat.setTint(wrappedDrawable, color); iconHolder.setImageDrawable(wrappedDrawable); iconHolder.invalidate(); }
Example 20
Source File: BarChartCard.java From ResearchStack with Apache License 2.0 | 4 votes |
private void initializeViews() { titleTextView = (TextView) findViewById(R.id.view_chart_bar_title); titleTextView.setText(titleText); titleTextView.setTextColor(titleTextColor); titleTextView.setTextSize(TypedValue.COMPLEX_UNIT_PX, titleTextSize); titleTextView.setTypeface(Typeface.create(titleTextTypeface, Typeface.NORMAL)); expand = (ImageView) findViewById(R.id.view_chart_line_expand); if (expandTintColor != 0) { Drawable drawable = expand.getDrawable(); drawable = DrawableCompat.wrap(drawable); DrawableCompat.setTint(drawable, expandTintColor); expand.setImageDrawable(drawable); } chart = (BarChart) findViewById(R.id.view_chart_bar); chart.getLegend().setEnabled(false); chart.setDescription(""); chart.setDrawBorders(false); chart.setDrawValueAboveBar(false); chart.setDrawGridBackground(false); chart.setDrawBarShadow(false); chart.setDrawHighlightArrow(false); chart.setPinchZoom(false); chart.setExtraLeftOffset(0); chart.setExtraRightOffset(0); chart.setExtraBottomOffset(8); chart.setExtraTopOffset(0); chart.setTouchEnabled(true); chart.setDragEnabled(true); XAxis xAxis = chart.getXAxis(); xAxis.setPosition(XAxis.XAxisPosition.BOTTOM); xAxis.setDrawAxisLine(false); xAxis.setYOffset(16); xAxis.setDrawGridLines(false); xAxis.setLabelsToSkip(0); xAxis.setTextSize(chartXAxisTextSize); xAxis.setTextColor(chartXAxisTextColor); xAxis.setTypeface(Typeface.create(chartXAxisTextTypeface, Typeface.NORMAL)); YAxis yAxisLeft = chart.getAxisLeft(); yAxisLeft.setDrawAxisLine(false); yAxisLeft.setDrawGridLines(false); yAxisLeft.setDrawZeroLine(false); yAxisLeft.setDrawLabels(false); YAxis yAxisRight = chart.getAxisRight(); yAxisRight.setDrawAxisLine(false); yAxisRight.setDrawGridLines(false); yAxisRight.setDrawZeroLine(false); yAxisRight.setDrawLabels(false); }