List of usage examples for android.support.v4.graphics.drawable DrawableCompat setTintList
public static void setTintList(Drawable drawable, ColorStateList colorStateList)
From source file:android.support.design.widget.FloatingActionButtonEclairMr1.java
@Override void setBackgroundTintList(ColorStateList tint) { if (mShapeDrawable != null) { DrawableCompat.setTintList(mShapeDrawable, tint); }//from w w w . j a v a2 s. c o m if (mBorderDrawable != null) { mBorderDrawable.setBorderTint(tint); } }
From source file:com.wanderingcan.persistentsearch.SearchMenuItem.java
/** * Sets the drawable for the action icon for the SearchMenuItem * @param icon The drawable for the action icon *///from w ww .j a v a 2s .c o m public SearchMenuItem setActionIcon(Drawable icon) { mDefaultAction = false; mActionDrawable = DrawableCompat.wrap(icon); if (mActionTint != null) { DrawableCompat.setTintList(mActionDrawable, mActionTint); } if (mActionTintMode != null) { DrawableCompat.setTintMode(mActionDrawable, mActionTintMode); } notifyItemChanged(); return this; }
From source file:com.bilibili.magicasakura.widgets.AppCompatImageHelper.java
private boolean applySupportImageTint() { Drawable image = ((ImageView) mView).getDrawable(); if (image != null && mImageTintInfo != null && mImageTintInfo.mHasTintList) { Drawable tintDrawable = image.mutate(); tintDrawable = DrawableCompat.wrap(tintDrawable); if (mImageTintInfo.mHasTintList) { DrawableCompat.setTintList(tintDrawable, mImageTintInfo.mTintList); }/*from www . j av a 2s . co m*/ if (mImageTintInfo.mHasTintMode) { DrawableCompat.setTintMode(tintDrawable, mImageTintInfo.mTintMode); } if (tintDrawable.isStateful()) { tintDrawable.setState(mView.getDrawableState()); } setImageDrawable(tintDrawable); if (image == tintDrawable) { tintDrawable.invalidateSelf(); } return true; } return false; }
From source file:com.commonsware.cwac.crossport.design.widget.FloatingActionButtonImpl.java
void setBackgroundDrawable(ColorStateList backgroundTint, PorterDuff.Mode backgroundTintMode, int rippleColor, int borderWidth) { // Now we need to tint the original background with the tint, using // an InsetDrawable if we have a border width mShapeDrawable = DrawableCompat.wrap(createShapeDrawable()); DrawableCompat.setTintList(mShapeDrawable, backgroundTint); if (backgroundTintMode != null) { DrawableCompat.setTintMode(mShapeDrawable, backgroundTintMode); }// w w w . j ava2 s . c o m // Now we created a mask Drawable which will be used for touch feedback. GradientDrawable touchFeedbackShape = createShapeDrawable(); // We'll now wrap that touch feedback mask drawable with a ColorStateList. We do not need // to inset for any border here as LayerDrawable will nest the padding for us mRippleDrawable = DrawableCompat.wrap(touchFeedbackShape); DrawableCompat.setTintList(mRippleDrawable, createColorStateList(rippleColor)); final Drawable[] layers; if (borderWidth > 0) { mBorderDrawable = createBorderDrawable(borderWidth, backgroundTint); layers = new Drawable[] { mBorderDrawable, mShapeDrawable, mRippleDrawable }; } else { mBorderDrawable = null; layers = new Drawable[] { mShapeDrawable, mRippleDrawable }; } mContentBackground = new LayerDrawable(layers); mShadowDrawable = new ShadowDrawableWrapper(mView.getContext(), mContentBackground, mShadowViewDelegate.getRadius(), mElevation, mElevation + mPressedTranslationZ); mShadowDrawable.setAddPaddingForCorners(false); mShadowViewDelegate.setBackgroundDrawable(mShadowDrawable); }
From source file:com.landenlabs.all_UiDemo.frag.RadioBtnFrag.java
private void addTabBar(RadioGroup tabHolder, float weight, int padding) { final int maxTabs = 4; // tabHolder.removeAllViews(); int[][] states = new int[][] { new int[] { android.R.attr.state_checked }, new int[] {} }; ColorStateList colorStateList = new ColorStateList(states, new int[] { 0xff00ff00, 0x80ff0000 }); RadioGroup.LayoutParams lp = new RadioGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT, weight); /*//from www . j av a 2 s . c om ViewOutlineProvider outlineBoundary; if (Build.VERSION.SDK_INT >= 21) { outlineBoundary = new ViewOutlineProvider() { @Override public void getOutline(View view, Outline outline) { outline.setRect(0, 0, 200, 60); // view.getMeasuredWidth(), view.getMeasuredHeight()); } }; } */ String[] pageNames = new String[] { "Home", "Map", "Hourly", "Daily" }; int tabCnt = 0; for (String pageName : pageNames) { RadioButton button = new RadioButton(tabHolder.getContext()); String resName = "tab_" + pageName.toLowerCase(); int resID = getResources().getIdentifier(resName, "drawable", this.getContext().getPackageName()); Drawable tabBtnIcon = getResources().getDrawable(resID); if (tabBtnIcon != null) { if (tabBtnIcon != null && Build.VERSION.SDK_INT >= 21) { tabBtnIcon.setTintMode(PorterDuff.Mode.MULTIPLY); tabBtnIcon.setTintList(colorStateList); } else { tabBtnIcon = DrawableCompat.wrap(tabBtnIcon); DrawableCompat.setTintList(tabBtnIcon.mutate(), colorStateList); DrawableCompat.setTintMode(tabBtnIcon.mutate(), PorterDuff.Mode.MULTIPLY); } // tabBtnIcon = tabHolder.getResources().getDrawable(android.R.drawable.btn_radio); if (Build.VERSION.SDK_INT >= 21) { // Hide standard radio button but leave ripple effect button.setButtonDrawable(null); } else { // Hide standard radio button button.setButtonDrawable(new StateListDrawable()); } button.setCompoundDrawablesWithIntrinsicBounds(null, tabBtnIcon, null, null); /* // button.setBackgroundResource(R.drawable.ripple_boarderless); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { button.setCompoundDrawablesWithIntrinsicBounds(null, tabBtnIcon, null, null); // button.setCompoundDrawablesRelativeWithIntrinsicBounds(null, tabBtnIcon, null, null); // tabBtnIcon.setBounds(0, 0, 50, 100); // img.getMinimumWidth(), img.getMinimumHeight()); // button.setCompoundDrawables(null, tabBtnIcon, null, null); } else { button.setCompoundDrawablesWithIntrinsicBounds(null, tabBtnIcon, null, null); } */ button.setBackgroundResource(R.drawable.ripple_boarderless); button.setPadding(padding, padding, padding, padding); button.setGravity(Gravity.CENTER); button.setTextColor(colorStateList); button.setText(pageName); tabHolder.addView(button, lp); if (++tabCnt == maxTabs) break; } } }
From source file:android.support.v7.graphics.drawable.DrawableWrapper.java
@Override public void setTintList(ColorStateList tint) { DrawableCompat.setTintList(mDrawable, tint); }
From source file:jp.tkgktyk.xposed.forcetouchdetector.app.util.fab.FloatingActionButtonEclairMr1.java
@Override void setBackgroundTintList(ColorStateList tint) { DrawableCompat.setTintList(mShapeDrawable, tint); if (mBorderDrawable != null) { DrawableCompat.setTintList(mBorderDrawable, tint); }/*w w w . j a va2s .c o m*/ }
From source file:com.negusoft.greenmatter.drawable.CompoundDrawableWrapper.java
@Override public void setTintList(ColorStateList tint) { for (Drawable d : mSecondaryDrawables) DrawableCompat.setTintList(d, tint); super.setTintList(tint); }
From source file:android.support.design.widget.FloatingActionButtonEclairMr1.java
@Override void setRippleColor(int rippleColor) { if (mRippleDrawable != null) { DrawableCompat.setTintList(mRippleDrawable, createColorStateList(rippleColor)); } }
From source file:com.tr4android.support.extension.picker.PickerThemeUtils.java
public static Drawable getNavButtonBackground(Context context) { Drawable drawable = ContextCompat.getDrawable(context, R.drawable.date_picker_nav_background); if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { // Proxy the highlight color into the background drawable drawable = DrawableCompat.wrap(drawable.mutate()); DrawableCompat.setTintList(drawable, getNavButtonColorStateList(context)); }/* ww w . j a v a 2 s .c o m*/ return drawable; }