本文整理汇总了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;
}
示例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();
}
}
}
示例3: setColorFilter
import android.graphics.ColorFilter; //导入依赖的package包/类
@Override
public void setColorFilter(ColorFilter cf) {
if (cf == mColorFilter) {
return;
}
mColorFilter = cf;
applyColorFilter();
invalidate();
}
示例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);
}
示例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);
}
}
示例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;
}
}
示例7: setColorFilter
import android.graphics.ColorFilter; //导入依赖的package包/类
@Override
public void setColorFilter(ColorFilter colorFilter) {
if (mAnimationBackend != null) {
mAnimationBackend.setColorFilter(colorFilter);
}
mColorFilter = colorFilter;
}
示例8: setColorFilter
import android.graphics.ColorFilter; //导入依赖的package包/类
@Override
public void setColorFilter(ColorFilter cf) {
if (cf == mColorFilter) {
return;
}
mColorFilter = cf;
applyColorFilter();
invalidate();
}
示例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());
}
示例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;
}
示例11: getColorFilter
import android.graphics.ColorFilter; //导入依赖的package包/类
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
@Override
public ColorFilter getColorFilter() {
return mDrawable.getColorFilter();
}
示例12: setColorFilter
import android.graphics.ColorFilter; //导入依赖的package包/类
@Override
public void setColorFilter(ColorFilter colorFilter) {
mRing.setColorFilter(colorFilter);
}
示例13: setColorFilter
import android.graphics.ColorFilter; //导入依赖的package包/类
public void setColorFilter(ColorFilter filter) {
mPaint.setColorFilter(filter);
invalidateSelf();
}
示例14: setColorFilter
import android.graphics.ColorFilter; //导入依赖的package包/类
@Override
public void setColorFilter(ColorFilter cf) {
mPaint.setColorFilter(cf);
}
示例15: setColorFilter
import android.graphics.ColorFilter; //导入依赖的package包/类
@Override
public void setColorFilter(ColorFilter cf) {
mPaint.setColorFilter(cf);
mCornerShadowPaint.setColorFilter(cf);
mEdgeShadowPaint.setColorFilter(cf);
}