Drawable setColorFilter - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Drawable setColorFilter method.

This code example shows how to use the following methods:setColorFilter
    image.setAlpha(alpha);
  } 
 
  @Override public void setColorFilter(ColorFilter cf) {
    if (placeholder != null) {
      placeholder.setColorFilter(cf);
    } 
    image.setColorFilter(cf);
  } 
 
  @Override public int getOpacity() { 
    return image.getOpacity();
  } 
 
  @Override protected void onBoundsChange(Rect bounds) {
    super.onBoundsChange(bounds);
 
    image.setBounds(bounds);
    if (placeholder != null) {
      // Center placeholder inside the image bounds 
7
CodeRank
This code example shows how to use the following methods:setColorFilter
This code example shows how to use the following methods:setColorFilter
        public void setAlpha(int alpha) {
            mRealDrawable.setAlpha(alpha);
        } 
        @Override 
        public void setColorFilter(ColorFilter cf) {
            mRealDrawable.setColorFilter(cf);
        } 
        @Override 
        public int getOpacity() { 
            return mRealDrawable.getOpacity();
        } 
    } 
 
    public TargetDrawable(Resources res, int resId) {
        this(res, resId == 0 ? null : res.getDrawable(resId));
    } 
 
    public TargetDrawable(Resources res, Drawable drawable) {
        // Mutate the drawable so we can animate shared drawable properties. 
        mDrawable = drawable != null ? drawable.mutate() : null;
7
CodeRank
This code example shows how to use the following methods:setColorFilter
        public void setAlpha(int alpha) {
            mRealDrawable.setAlpha(alpha);
        } 
        @Override 
        public void setColorFilter(ColorFilter cf) {
            mRealDrawable.setColorFilter(cf);
        } 
        @Override 
        public int getOpacity() { 
            return mRealDrawable.getOpacity();
        } 
    } 
 
    public TargetDrawable(Resources res, int resId) {
        mResourceId = resId;
        setDrawable(res, resId);
    } 
 
    public void setDrawable(Resources res, int resId) {
        // Note we explicitly don't set mResourceId to resId since we allow the drawable to be 
7
CodeRank
This code example shows how to use the following methods:setColorFilter
		mDrawable.setDither( dither );
	} 
 
	@Override 
	public void setColorFilter( int color, Mode mode ) {
		mDrawable.setColorFilter( color, mode );
	} 
 
	@Override 
	public void invalidateSelf() { 
		mDrawable.invalidateSelf();
	} 
 
	@Override 
	public boolean isStateful() { 
		return mDrawable.isStateful();
	} 
 
	@Override 
	protected void onBoundsChange( Rect bounds ) {
6
CodeRank
This code example shows how to use the following methods:setAlpha, setBounds, setColorFilter, setDither, setLevel
        final long now = SystemClock.uptimeMillis();
        boolean animating = false;
        if (mCurrDrawable != null) {
            if (mEnterAnimationEnd != 0) {
                if (mEnterAnimationEnd <= now) {
                    mCurrDrawable.setAlpha(mAlpha);
                    mEnterAnimationEnd = 0;
                } else { 
                    int animAlpha = (int) ((mEnterAnimationEnd - now) * 255)
                            / mDrawableContainerState.mEnterFadeDuration;
                    mCurrDrawable.setAlpha((255 - animAlpha) * mAlpha / 255);
                    animating = true;
                } 
            } 
        } else { 
            mEnterAnimationEnd = 0;
        } 
        if (mLastDrawable != null) {
            if (mExitAnimationEnd != 0) {
                if (mExitAnimationEnd <= now) {

6
CodeRank
This code example shows how to use the following methods:setColorFilter
        public void setAlpha(int alpha) {
            mRealDrawable.setAlpha(alpha);
        } 
        @Override 
        public void setColorFilter(ColorFilter cf) {
            mRealDrawable.setColorFilter(cf);
        } 
        @Override 
        public int getOpacity() { 
            return mRealDrawable.getOpacity();
        } 
    } 
 
    public TargetDrawable(Resources res, int resId) {
        this(res, resId == 0 ? null : res.getDrawable(resId));
    } 
 
    public TargetDrawable(Resources res, Drawable drawable) {
        // Mutate the drawable so we can animate shared drawable properties. 
        mDrawable = drawable != null ? drawable.mutate() : null;
6
CodeRank
This code example shows how to use the following methods:clearColorFilter, draw, getIntrinsicHeight, getIntrinsicWidth, setBounds
    private void drawAddTransitionIcons(Canvas canvas) {
        if (hasSpaceForAddTransitionIcons()) { 
            boolean canPick = canPickTransition();
            if (mMediaItem.getBeginTransition() == null) {
                if (!canPick) {
                    sAddTransitionDrawable.setColorFilter(COLOR_DISABLED, PorterDuff.Mode.DST_OUT);
                } 
                sAddTransitionDrawable.setState(mLeftState);
                sAddTransitionDrawable.setBounds(getPaddingLeft(), getPaddingTop(),
                        sAddTransitionDrawable.getIntrinsicWidth() + getPaddingLeft(),
                        getPaddingTop() + sAddTransitionDrawable.getIntrinsicHeight());
                sAddTransitionDrawable.draw(canvas);
                sAddTransitionDrawable.clearColorFilter();
            } 
 
            if (mMediaItem.getEndTransition() == null) {
                if (!canPick) {
                    sAddTransitionDrawable.setColorFilter(COLOR_DISABLED, PorterDuff.Mode.DST_OUT);
                } 
                sAddTransitionDrawable.setState(mRightState);

6
CodeRank
This code example shows how to use the following methods:setColorFilter
            mWrapped.setColorFilter(cf);
        } 
 
        @Override 
        public void setColorFilter(int color, PorterDuff.Mode mode) {
            mWrapped.setColorFilter(color, mode);
        } 
 
        @Override 
        public void clearColorFilter() { 
            mWrapped.clearColorFilter();
        } 
 
        @Override 
        public boolean isStateful() { 
            return mWrapped.isStateful();
        } 
 
        @Override 
        public boolean setState(int[] stateSet) {
6
CodeRank
This code example shows how to use the following methods:draw, getIntrinsicHeight, getIntrinsicWidth, setColorFilter, setBounds
    public static Bitmap recolorBitmap(BitmapDrawable drawable, int color) {
        if (drawable == null) {
            return null; 
        } 
 
        Bitmap outBitmap = Bitmap.createBitmap(drawable.getIntrinsicWidth(),
                drawable.getIntrinsicHeight(), Bitmap.Config.ARGB_8888);
        Canvas canvas = new Canvas(outBitmap);
        drawable.setBounds(0, 0, outBitmap.getWidth(), outBitmap.getHeight());
        drawable.setColorFilter(color,
                PorterDuff.Mode.SRC_IN);
        drawable.draw(canvas);
        drawable.setColorFilter(null);
        drawable.setCallback(null); // free up any references
        return outBitmap;
    } 
 
    public static Intent getDefaultClockIntent(Context context) {
        PackageManager pm = context.getPackageManager();
        for (String packageName : CLOCK_PACKAGES) {
6
CodeRank

Related Drawable setColorFilter Questions & Answers:

setColorFilter Method Overview
Specify an optional colorFilter for the drawable.
See Code Examples for other Android Drawable Methods: