当前位置: 首页>>代码示例>>Java>>正文


Java ColorFilter类代码示例

本文整理汇总了Java中android.graphics.ColorFilter的典型用法代码示例。如果您正苦于以下问题:Java ColorFilter类的具体用法?Java ColorFilter怎么用?Java ColorFilter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ColorFilter类属于android.graphics包,在下文中一共展示了ColorFilter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getThemedBitmap

import android.graphics.ColorFilter; //导入依赖的package包/类
/**
 * Gets the icon with an applied color filter
 * for the correct theme.
 *
 * @param context the context to use.
 * @param res     the drawable resource to use.
 * @param dark    true for icon suitable for use with a dark theme,
 *                false for icon suitable for use with a light theme.
 * @return a themed icon.
 */
@NonNull
public static Bitmap getThemedBitmap(@NonNull Context context, @DrawableRes int res, boolean dark) {
    int color = dark ? getIconDarkThemeColor(context) : getIconLightThemeColor(context);

    Bitmap sourceBitmap = getBitmapFromVectorDrawable(context, res);
    Bitmap resultBitmap = Bitmap.createBitmap(sourceBitmap.getWidth(), sourceBitmap.getHeight(),
        Bitmap.Config.ARGB_8888);
    Paint p = new Paint();
    ColorFilter filter = new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_IN);
    p.setColorFilter(filter);
    Canvas canvas = new Canvas(resultBitmap);
    canvas.drawBitmap(sourceBitmap, 0, 0, p);
    sourceBitmap.recycle();
    return resultBitmap;
}
 
开发者ID:XndroidDev,项目名称:Xndroid,代码行数:26,代码来源:ThemeUtils.java

示例2: applyTheme

import android.graphics.ColorFilter; //导入依赖的package包/类
public void applyTheme(boolean dark) {
    ColorFilter cf = new PorterDuffColorFilter(Color.WHITE, PorterDuff.Mode.SRC_ATOP);
    for (Drawable d : mIcons) {
        if (dark) {
            d.setColorFilter(cf);
        } else {
            d.clearColorFilter();
        }
    }
}
 
开发者ID:Vinetos,项目名称:Hello-Music-droid,代码行数:11,代码来源:FolderAdapter.java

示例3: setColorFilter

import android.graphics.ColorFilter; //导入依赖的package包/类
@Override
public void setColorFilter(ColorFilter cf) {
    if (cf == mColorFilter) {
        return;
    }

    mColorFilter = cf;
    applyColorFilter();
    invalidate();
}
 
开发者ID:hushengjun,项目名称:FastAndroid,代码行数:11,代码来源:CircleImageView.java

示例4: renderGo

import android.graphics.ColorFilter; //导入依赖的package包/类
private void renderGo(Canvas canvas, ColorFilter filter, Paint paint, int i) {
    if (i >= 0 && i <= 8) {
        renderByProvince1(i);
    } else if (i >= 9 && i <= 19) {
        renderByProvince2(i);
    } else if (i >= 20 && i <= 29) {
        renderByProvince3(i);
    } else if (i >= 29 && i <= 33) {
        renderByProvince4(i);
    }
    mRenderPath.addPath(mPath, mFinalPathMatrix);
    paint.setStrokeJoin(Paint.Join.MITER);
    paint.setStrokeCap(Paint.Cap.BUTT);
    paint.setStrokeMiter(4.0f);
    paint.setColorFilter(filter);
    canvas.drawPath(mRenderPath, paint);

    // Region
    mRegion = mRegionList.get(i);
    mRegion.setPath(mRenderPath, mGlobalRegion);
    mRegionList.set(i, mRegion);

    mPath.reset();
    mRenderPath.reset();

    mFinalPathMatrix.setValues(
            new float[]{1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f}
    );
    mFinalPathMatrix.postScale(scaleX, scaleY);
}
 
开发者ID:Sora-Shiro,项目名称:ChinaMapInfoView,代码行数:31,代码来源:CnSvgBigRenderer.java

示例5: setColorFilter

import android.graphics.ColorFilter; //导入依赖的package包/类
public void setColorFilter(ColorFilter colorFilter) {
    if (this.mDelegateDrawable != null) {
        this.mDelegateDrawable.setColorFilter(colorFilter);
    } else {
        this.mAnimatedVectorState.mVectorDrawable.setColorFilter(colorFilter);
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:8,代码来源:AnimatedVectorDrawableCompat.java

示例6: getColorFilter

import android.graphics.ColorFilter; //导入依赖的package包/类
/**
 * @see android.graphics.drawable.Drawable#getColorFilter().
 */
@SuppressWarnings("NewApi")
public static ColorFilter getColorFilter(Drawable drawable) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        return drawable.getColorFilter();
    } else {
        return null;
    }
}
 
开发者ID:lizhangqu,项目名称:chromium-net-for-android,代码行数:12,代码来源:ApiCompatibilityUtils.java

示例7: setColorFilter

import android.graphics.ColorFilter; //导入依赖的package包/类
@Override
public void setColorFilter(ColorFilter colorFilter) {
  if (mAnimationBackend != null) {
    mAnimationBackend.setColorFilter(colorFilter);
  }
  mColorFilter = colorFilter;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:8,代码来源:AnimationBackendDelegate.java

示例8: setColorFilter

import android.graphics.ColorFilter; //导入依赖的package包/类
@Override
public void setColorFilter(ColorFilter cf) {
    if (cf == mColorFilter) {
        return;
    }
    mColorFilter = cf;
    applyColorFilter();
    invalidate();
}
 
开发者ID:yangwencan2002,项目名称:RotateCircleImageView,代码行数:10,代码来源:RotateCircleImageView.java

示例9: testSetDrawablePropertiesDefault

import android.graphics.ColorFilter; //导入依赖的package包/类
@Test
public void testSetDrawablePropertiesDefault() {
  DrawableProperties properties = new DrawableProperties();
  Drawable drawableTo = mock(Drawable.class);
  DrawableUtils.setDrawableProperties(drawableTo, properties);
  verify(drawableTo, never()).setAlpha(anyInt());
  verify(drawableTo, never()).setColorFilter(any(ColorFilter.class));
  verify(drawableTo, never()).setDither(anyBoolean());
  verify(drawableTo, never()).setFilterBitmap(anyBoolean());
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:11,代码来源:DrawableUtilsTest.java

示例10: setIconColorFilter

import android.graphics.ColorFilter; //导入依赖的package包/类
/**
 * Set the icon color for the Alert
 *
 * @param colorFilter ColorFilter
 * @return This Alerter
 */
public Alerter setIconColorFilter(@NonNull final ColorFilter colorFilter) {
    if (getAlert() != null) {
        getAlert().setIconColorFilter(colorFilter);
    }

    return this;
}
 
开发者ID:Tapadoo,项目名称:Alerter,代码行数:14,代码来源:Alerter.java

示例11: getColorFilter

import android.graphics.ColorFilter; //导入依赖的package包/类
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
@Override
public ColorFilter getColorFilter() {
    return mDrawable.getColorFilter();
}
 
开发者ID:MCMrARM,项目名称:revolution-irc,代码行数:6,代码来源:DrawableWrapper.java

示例12: setColorFilter

import android.graphics.ColorFilter; //导入依赖的package包/类
@Override
public void setColorFilter(ColorFilter colorFilter) {
  mRing.setColorFilter(colorFilter);
}
 
开发者ID:weexext,项目名称:ucar-weex-core,代码行数:5,代码来源:MaterialProgressDrawable.java

示例13: setColorFilter

import android.graphics.ColorFilter; //导入依赖的package包/类
public void setColorFilter(ColorFilter filter) {
    mPaint.setColorFilter(filter);
    invalidateSelf();
}
 
开发者ID:scwang90,项目名称:SmartRefreshLayout,代码行数:5,代码来源:MaterialProgressDrawable.java

示例14: setColorFilter

import android.graphics.ColorFilter; //导入依赖的package包/类
@Override
public void setColorFilter(ColorFilter cf) {
    mPaint.setColorFilter(cf);
}
 
开发者ID:zacharee,项目名称:SliderPreferenceEmbedded,代码行数:5,代码来源:StateDrawable.java

示例15: setColorFilter

import android.graphics.ColorFilter; //导入依赖的package包/类
@Override
public void setColorFilter(ColorFilter cf) {
    mPaint.setColorFilter(cf);
    mCornerShadowPaint.setColorFilter(cf);
    mEdgeShadowPaint.setColorFilter(cf);
}
 
开发者ID:zuoweitan,项目名称:Hitalk,代码行数:7,代码来源:RoundRectDrawableWithShadow.java


注:本文中的android.graphics.ColorFilter类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。