当前位置: 首页>>代码示例>>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;未经允许,请勿转载。