當前位置: 首頁>>代碼示例>>Java>>正文


Java DrawableCompat.setTintList方法代碼示例

本文整理匯總了Java中android.support.v4.graphics.drawable.DrawableCompat.setTintList方法的典型用法代碼示例。如果您正苦於以下問題:Java DrawableCompat.setTintList方法的具體用法?Java DrawableCompat.setTintList怎麽用?Java DrawableCompat.setTintList使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.support.v4.graphics.drawable.DrawableCompat的用法示例。


在下文中一共展示了DrawableCompat.setTintList方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onAttachedToWindow

import android.support.v4.graphics.drawable.DrawableCompat; //導入方法依賴的package包/類
@Override
    protected void onAttachedToWindow() {
        super.onAttachedToWindow();
        super.setOnClickListener(this);
//        setScaleType(ScaleType.CENTER_INSIDE);
//        if (getTag() != null && TextUtils.equals("checked", getTag().toString())) {
//            setChecked(true);
//        }

        if (!isInEditMode() && isTintColor) {
            ColorStateList stateList = new ColorStateList(
                    new int[][]{{android.R.attr.state_checked}, {}},
                    new int[]{SkinHelper.getSkin().getThemeSubColor(), ContextCompat.getColor(getContext(), R.color.default_base_bg_disable)});
            DrawableCompat.setTintList(getDrawable(), stateList);
        }
    }
 
開發者ID:angcyo,項目名稱:RLibrary,代碼行數:17,代碼來源:RImageCheckView.java

示例2: getDrawableByState

import android.support.v4.graphics.drawable.DrawableCompat; //導入方法依賴的package包/類
private Drawable getDrawableByState(Context context, int state) {
    switch (state) {
        case PlaybackStateCompat.STATE_NONE:
            Drawable pauseDrawable = ContextCompat.getDrawable(context, R.drawable.ic_play);
            DrawableCompat.setTintList(pauseDrawable, colorPlay);
            return pauseDrawable;
        case PlaybackStateCompat.STATE_PLAYING:
            AnimationDrawable animation = (AnimationDrawable) ContextCompat.getDrawable(context, R.drawable.equalizer);
            DrawableCompat.setTintList(animation, colorPlay);
            animation.start();
            return animation;
        case PlaybackStateCompat.STATE_PAUSED:
            Drawable playDrawable = ContextCompat.getDrawable(context, R.drawable.equalizer);
            DrawableCompat.setTintList(playDrawable, colorPause);
            return playDrawable;
        default:
            Drawable noneDrawable = ContextCompat.getDrawable(context, R.drawable.ic_play);
            DrawableCompat.setTintList(noneDrawable, colorPlay);
            return noneDrawable;
    }
}
 
開發者ID:dibakarece,項目名稱:DMAudioStreamer,代碼行數:22,代碼來源:AdapterMusic.java

示例3: setCustomColor

import android.support.v4.graphics.drawable.DrawableCompat; //導入方法依賴的package包/類
public void setCustomColor(@ColorInt int colorBackground, @ColorInt int colorProgress, @ColorInt int colorCircle) {
    DrawableCompat.setTintList(DrawableCompat.wrap(getTrackDrawable()), new ColorStateList(
            new int[][]{
                    new int[]{android.R.attr.state_checked},
                    new int[]{}
            },
            new int[]{
                    colorProgress,
                    colorBackground
            }
    ));

    DrawableCompat.setTintList(DrawableCompat.wrap(getThumbDrawable()), new ColorStateList(
            new int[][]{
                    new int[]{android.R.attr.state_checked},
                    new int[]{}
            },
            new int[]{
                    colorCircle,
                    colorProgress
            }
    ));
}
 
開發者ID:AppliKey,項目名稱:Sunstrike,代碼行數:24,代碼來源:CustomSwitch.java

示例4: setBackgroundDrawable

import android.support.v4.graphics.drawable.DrawableCompat; //導入方法依賴的package包/類
void setBackgroundDrawable(ColorStateList backgroundTint, Mode backgroundTintMode, int rippleColor, int borderWidth) {
    Drawable[] layers;
    this.mShapeDrawable = DrawableCompat.wrap(createShapeDrawable());
    DrawableCompat.setTintList(this.mShapeDrawable, backgroundTint);
    if (backgroundTintMode != null) {
        DrawableCompat.setTintMode(this.mShapeDrawable, backgroundTintMode);
    }
    this.mRippleDrawable = DrawableCompat.wrap(createShapeDrawable());
    DrawableCompat.setTintList(this.mRippleDrawable, createColorStateList(rippleColor));
    if (borderWidth > 0) {
        this.mBorderDrawable = createBorderDrawable(borderWidth, backgroundTint);
        layers = new Drawable[]{this.mBorderDrawable, this.mShapeDrawable, this.mRippleDrawable};
    } else {
        this.mBorderDrawable = null;
        layers = new Drawable[]{this.mShapeDrawable, this.mRippleDrawable};
    }
    this.mContentBackground = new LayerDrawable(layers);
    this.mShadowDrawable = new ShadowDrawableWrapper(this.mView.getResources(), this.mContentBackground, this.mShadowViewDelegate.getRadius(), this.mElevation, this.mElevation + this.mPressedTranslationZ);
    this.mShadowDrawable.setAddPaddingForCorners(false);
    this.mShadowViewDelegate.setBackgroundDrawable(this.mShadowDrawable);
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:22,代碼來源:FloatingActionButtonEclairMr1.java

示例5: forIdWithColors

import android.support.v4.graphics.drawable.DrawableCompat; //導入方法依賴的package包/類
public static Drawable forIdWithColors(Context context, int blackDrawableId, int baseId, int disabledId, int pressedId, int selectedId) {
    Drawable drawable = DrawableCompat.wrap(ContextCompat.getDrawable(context, blackDrawableId));
    int baseColor = ContextCompat.getColor(context, baseId);
    int disabledColor = ContextCompat.getColor(context, disabledId);
    int pressedColor = ContextCompat.getColor(context, pressedId);
    int selectedColor = ContextCompat.getColor(context, selectedId);
    int[][] states = new int[4][];
    states[0] = new int[]{-android.R.attr.state_enabled};
    states[1] = new int[]{android.R.attr.state_pressed};
    states[2] = new int[]{android.R.attr.state_selected};
    states[3] = new int[]{android.R.attr.state_enabled};
    DrawableCompat.setTintList(drawable, new ColorStateList(states, new int[]{disabledColor, pressedColor, selectedColor, baseColor}));
    DrawableCompat.setTintMode(drawable, Mode.SRC_IN);
    return drawable;
}
 
開發者ID:Bruno125,項目名稱:Unofficial-Ups,代碼行數:16,代碼來源:ColorizedDrawable.java

示例6: install

import android.support.v4.graphics.drawable.DrawableCompat; //導入方法依賴的package包/類
public static void install(SeekBar seekBar, AttributeSet attrs) {
    ThemedView.setupBackground(seekBar, attrs);
    if (ThemeHelper.hasCustomAccentColor(seekBar.getContext())) {
        int accentColor = ThemeHelper.getAccentColor(seekBar.getContext());
        LayerDrawable ld = (LayerDrawable) seekBar.getProgressDrawable();
        ld.findDrawableByLayerId(android.R.id.progress).setColorFilter(accentColor,
                PorterDuff.Mode.SRC_IN);

        DrawableCompat.setTintList(seekBar.getThumb().mutate(),
                createSeekBarThumbColorList(seekBar.getContext()));
    }
}
 
開發者ID:MCMrARM,項目名稱:revolution-irc,代碼行數:13,代碼來源:ThemedSeekBar.java

示例7: setTint

import android.support.v4.graphics.drawable.DrawableCompat; //導入方法依賴的package包/類
public static void setTint(@NonNull RadioButton radioButton,
                           @NonNull ColorStateList colors) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        radioButton.setButtonTintList(colors);
    } else {
        Drawable radioDrawable = ContextCompat.getDrawable(radioButton.getContext(),
                R.drawable.abc_btn_radio_material);
        Drawable d = DrawableCompat.wrap(radioDrawable);
        DrawableCompat.setTintList(d, colors);
        radioButton.setButtonDrawable(d);
    }
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:13,代碼來源:MDTintHelper.java

示例8: setContent

import android.support.v4.graphics.drawable.DrawableCompat; //導入方法依賴的package包/類
public void setContent(@DrawableRes int iconResId, @StringRes int titleResId) {
    if (iconResId > 0) {
        Drawable icon = DrawableCompat.wrap(ContextCompat.getDrawable(getContext(), iconResId));
        if (mIconTints != null) {
            DrawableCompat.setTintList(icon, mIconTints);
        }
        ((ImageView) findViewById(R.id.icon)).setImageDrawable(icon);
    }
    ((TextView) findViewById(R.id.title)).setText(titleResId);
}
 
開發者ID:dreaminglion,項目名稱:iosched-reader,代碼行數:11,代碼來源:NavDrawerItemView.java

示例9: setTintList

import android.support.v4.graphics.drawable.DrawableCompat; //導入方法依賴的package包/類
public void setTintList(ColorStateList tint) {
    if (this.mDelegateDrawable != null) {
        DrawableCompat.setTintList(this.mDelegateDrawable, tint);
        return;
    }
    VectorDrawableCompatState state = this.mVectorState;
    if (state.mTint != tint) {
        state.mTint = tint;
        this.mTintFilter = updateTintFilter(this.mTintFilter, tint, state.mTintMode);
        invalidateSelf();
    }
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:13,代碼來源:VectorDrawableCompat.java

示例10: tintDrawable

import android.support.v4.graphics.drawable.DrawableCompat; //導入方法依賴的package包/類
public static Drawable tintDrawable(Context context, Drawable drawable, int tintAttr) {
    // start of FIX - tinting the drawable manually because the android:tint attribute crashes the app
    Drawable wrapped = DrawableCompat.wrap(drawable);

    TypedArray arr = context.obtainStyledAttributes(new int[]{tintAttr});
    ColorStateList tintList = Utils.getColorStateList(context, arr, 0);
    arr.recycle();

    if (tintList != null) {
        DrawableCompat.setTintList(wrapped, tintList);
    }

    return wrapped;
    // end of FIX
}
 
開發者ID:Gericop,項目名稱:DateTimePicker,代碼行數:16,代碼來源:Utils.java

示例11: setFabIconTint

import android.support.v4.graphics.drawable.DrawableCompat; //導入方法依賴的package包/類
@Override
public BottomSheetNumberPadTimePickerThemer setFabIconTint(ColorStateList tint) {
    if (tint != null) {
        int[] colors = extractColors(tint, STATES_FAB_COLORS);
        if (mFabIconTintAnimator != null) {
            mFabIconTintAnimator.setIntValues(colors);
        } else {
            mFabIconTintAnimator = createFabIconTintAnimator(colors);
        }
    }
    DrawableCompat.setTintList(mOkButton.getDrawable(), tint);
    return this;
}
 
開發者ID:philliphsu,項目名稱:NumberPadTimePicker,代碼行數:14,代碼來源:NumberPadTimePickerBottomSheetComponent.java

示例12: setBackgroundDrawable

import android.support.v4.graphics.drawable.DrawableCompat; //導入方法依賴的package包/類
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);
    }

    // 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);
}
 
開發者ID:commonsguy,項目名稱:cwac-crossport,代碼行數:39,代碼來源:FloatingActionButtonImpl.java

示例13: render

import android.support.v4.graphics.drawable.DrawableCompat; //導入方法依賴的package包/類
public void render(@Nullable final SearchSuggestionRVItem item,
                   @Nullable final OnClickListener listener) {
    if (!hasContext() || item == null) {
        return;
    }

    mItem = item;
    if (listener != null) {
        mListener = listener;
    }

    mSuggestionField.setText(item.getSuggestion());

    if (mSuggestionField instanceof TintableBackgroundView) {
        // "AppCompatTextView" and "com.android.support:appcompat-v7" are used, tint all states
        ViewCompat.setBackgroundTintList(mSuggestionField,
                new ColorStateList(STATES, new int[]{
                        AbstractColorUtils.getColor(getContext(), item.getPlaceholder()),
                        AbstractColorUtils.getColor(getContext(), R.color.tenor_sdk_primary_color)}));
        return;
    }

    // "com.android.support:appcompat-v7" is likely not being used, and thus "TextView" is used
    Drawable background = mSuggestionField.getBackground();
    if (background instanceof TintAwareDrawable) {
        // tint all states of the given drawable
        DrawableCompat.setTintList(background,
                new ColorStateList(STATES, new int[]{
                        AbstractColorUtils.getColor(getContext(), item.getPlaceholder()),
                        AbstractColorUtils.getColor(getContext(), R.color.tenor_sdk_primary_color)}));
        return;
    }

    // last option, tint only the background individually
    AbstractDrawableUtils.setDrawableTint(getContext(), background, item.getPlaceholder());
}
 
開發者ID:Tenor-Inc,項目名稱:tenor-android-demo-search,代碼行數:37,代碼來源:SearchSuggestionVH.java

示例14: tintDrawable

import android.support.v4.graphics.drawable.DrawableCompat; //導入方法依賴的package包/類
public Drawable tintDrawable(Drawable drawable, ColorStateList colors) {
    Drawable wrappedDrawable = DrawableCompat.wrap(drawable);
    DrawableCompat.setTintList(wrappedDrawable, colors);
    return wrappedDrawable;
}
 
開發者ID:lijunyandev,項目名稱:MeetMusic,代碼行數:6,代碼來源:ScanView.java

示例15: initSearchView

import android.support.v4.graphics.drawable.DrawableCompat; //導入方法依賴的package包/類
private void initSearchView() {
    SearchView searchView = mBinding.svSearch;
    //設置搜索框左邊距
    LinearLayout editFrame = (LinearLayout) findViewById(R.id.search_edit_frame);
    LinearLayout.LayoutParams editP = (LayoutParams) editFrame.getLayoutParams();
    editP.leftMargin = 0;
    editP.rightMargin = 0;
    ImageView imageView = (ImageView) findViewById(R.id.search_mag_icon);
    imageView.setAdjustViewBounds(true);
    imageView.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
    LinearLayout.LayoutParams lp3 = (LayoutParams) imageView.getLayoutParams();
    lp3.gravity = Gravity.CENTER_VERTICAL;
    lp3.leftMargin = (int) (DensityUtil.dip2px(8f) * DensityUtil.getBaseScale(getContext()));
    lp3.rightMargin = (int) (DensityUtil.dip2px(-2f) * DensityUtil.getBaseScale(getContext()));

    View view = searchView.findViewById(R.id.search_plate);
    view.setBackgroundColor(getResources().getColor(R.color.colorTransparent));
    EditText editText = (EditText) searchView.findViewById(R.id.search_src_text);
    editText.setBackgroundColor(Color.TRANSPARENT);
    editText.setTextSize(11.5f);
    editText.setTextColor(getResources().getColor(R.color.colorText));
    editText.setHintTextColor(getResources().getColor(R.color.colorHint));
    try {
        Field fCursorDrawableRes = TextView.class.getDeclaredField("mCursorDrawableRes");
        fCursorDrawableRes.setAccessible(true);
        int mCursorDrawableRes = fCursorDrawableRes.getInt(editText);
        Field fEditor = TextView.class.getDeclaredField("mEditor");
        fEditor.setAccessible(true);
        Object editor = fEditor.get(editText);
        Class<?> clazz = editor.getClass();
        Field fCursorDrawable = clazz.getDeclaredField("mCursorDrawable");
        fCursorDrawable.setAccessible(true);
        if (mCursorDrawableRes <= 0) return;
        Drawable cursorDrawable = ContextCompat.getDrawable(searchView.getContext(), mCursorDrawableRes);
        if (cursorDrawable == null) return;
        Drawable tintDrawable = DrawableCompat.wrap(cursorDrawable);
        DrawableCompat.setTintList(tintDrawable, ColorStateList.valueOf(ContextCompat.getColor(getContext(), R.color.bg_search)));
        Drawable[] drawables = new Drawable[]{tintDrawable, tintDrawable};
        fCursorDrawable.set(editor, drawables);
    } catch (Throwable t) {
        t.printStackTrace();
    }
}
 
開發者ID:xieyangxuejun,項目名稱:SearchLayout,代碼行數:44,代碼來源:FlowSearchLayout.java


注:本文中的android.support.v4.graphics.drawable.DrawableCompat.setTintList方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。