本文整理了Java中android.graphics.drawable.Drawable.setColorFilter()
方法的一些代码示例,展示了Drawable.setColorFilter()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Drawable.setColorFilter()
方法的具体详情如下:
包路径:android.graphics.drawable.Drawable
类名称:Drawable
方法名:setColorFilter
暂无
代码示例来源:origin: bumptech/glide
@Override
public void setColorFilter(ColorFilter colorFilter) {
wrapped.setColorFilter(colorFilter);
}
代码示例来源:origin: stackoverflow.com
COLOR2 = Color.parseColor("#FF"+getColor());
Mode mMode = Mode.SRC_ATOP;
Drawable d = mCtx.getResources().getDrawable(R.drawable.image);
d.setColorFilter(COLOR2,mMode)
代码示例来源:origin: facebook/litho
@Override
public void setColorFilter(ColorFilter cf) {
if (mDrawable == null) {
return;
}
mDrawable.setColorFilter(cf);
}
代码示例来源:origin: rey5137/material
@Override
public void setColorFilter(ColorFilter filter) {
if(mBackgroundDrawable != null)
mBackgroundDrawable.setColorFilter(filter);
}
代码示例来源:origin: rey5137/material
@Override
public void setColorFilter(ColorFilter cf) {
if(mDrawable != null)
mDrawable.setColorFilter(cf);
}
代码示例来源:origin: facebook/litho
@Override
public void setColorFilter(ColorFilter cf) {
mDrawable.setColorFilter(cf);
}
代码示例来源:origin: facebook/litho
@Override
public void setColorFilter(ColorFilter filter) {
mDrawable.setColorFilter(filter);
}
代码示例来源:origin: bumptech/glide
@Override
public void setColorFilter(int color, @NonNull PorterDuff.Mode mode) {
wrapped.setColorFilter(color, mode);
}
代码示例来源:origin: stackoverflow.com
Drawable mDrawable = context.getResources().getDrawable(R.drawable.balloons);
mDrawable.setColorFilter(new
PorterDuffColorFilter(0xffff00,PorterDuff.Mode.MULTIPLY));
代码示例来源:origin: stackoverflow.com
Drawable drawable = menuItem.getIcon();
if (drawable != null) {
// If we don't mutate the drawable, then all drawable's with this id will have a color
// filter applied to it.
drawable.mutate();
drawable.setColorFilter(color, PorterDuff.Mode.SRC_ATOP);
drawable.setAlpha(alpha);
}
代码示例来源:origin: GrenderG/Toasty
static Drawable tintIcon(@NonNull Drawable drawable, @ColorInt int tintColor) {
drawable.setColorFilter(tintColor, PorterDuff.Mode.SRC_IN);
return drawable;
}
代码示例来源:origin: square/picasso
@Override public void setColorFilter(ColorFilter cf) {
if (placeholder != null) {
placeholder.setColorFilter(cf);
}
super.setColorFilter(cf);
}
代码示例来源:origin: aa112901/remusic
public void setIconColor(Drawable icon) {
int textColorSecondary = android.R.attr.textColorSecondary;
TypedValue value = new TypedValue();
if (!mContext.getTheme().resolveAttribute(textColorSecondary, value, true)) {
return;
}
int baseColor = mContext.getResources().getColor(value.resourceId);
icon.setColorFilter(baseColor, PorterDuff.Mode.MULTIPLY);
}
}
代码示例来源:origin: zhihu/Matisse
public void setColor(int color) {
if (mDrawable == null) {
mDrawable = getDrawable();
}
mDrawable.setColorFilter(color, PorterDuff.Mode.SRC_IN);
}
}
代码示例来源:origin: k9mail/k-9
private void setCryptoStatusView(RecipientTokenHolder holder, @DrawableRes int cryptoStatusRes,
@AttrRes int cryptoStatusColorAttr) {
Resources resources = context.getResources();
Drawable drawable = resources.getDrawable(cryptoStatusRes);
// noinspection ConstantConditions, we know the resource exists!
drawable.mutate();
int cryptoStatusColor = ThemeUtils.getStyledColor(context, cryptoStatusColorAttr);
drawable.setColorFilter(cryptoStatusColor, Mode.SRC_ATOP);
holder.itemCryptoStatusIcon.setImageDrawable(drawable);
holder.itemCryptoStatus.setVisibility(View.VISIBLE);
}
代码示例来源:origin: stackoverflow.com
protected Drawable convertToGrayscale(Drawable drawable)
{
ColorMatrix matrix = new ColorMatrix();
matrix.setSaturation(0);
ColorMatrixColorFilter filter = new ColorMatrixColorFilter(matrix);
drawable.setColorFilter(filter);
return drawable;
}
代码示例来源:origin: zhihu/Matisse
public void setChecked(boolean enable) {
if (enable) {
setImageResource(R.drawable.ic_preview_radio_on);
mDrawable = getDrawable();
mDrawable.setColorFilter(mSelectedColor, PorterDuff.Mode.SRC_IN);
} else {
setImageResource(R.drawable.ic_preview_radio_off);
mDrawable = getDrawable();
mDrawable.setColorFilter(mUnSelectUdColor, PorterDuff.Mode.SRC_IN);
}
}
代码示例来源:origin: naman14/Timber
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();
}
}
}
代码示例来源:origin: TeamNewPipe/NewPipe
@Override
public void onBlocked() {
super.onBlocked();
controlsVisibilityHandler.removeCallbacksAndMessages(null);
animateView(controlsRoot, false, DEFAULT_CONTROLS_DURATION);
playbackSeekBar.setEnabled(false);
// Bug on lower api, disabling and enabling the seekBar resets the thumb color -.-, so sets the color again
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN)
playbackSeekBar.getThumb().setColorFilter(Color.RED, PorterDuff.Mode.SRC_IN);
loadingPanel.setBackgroundColor(Color.BLACK);
animateView(loadingPanel, true, 0);
animateView(surfaceForeground, true, 100);
}
代码示例来源:origin: TeamNewPipe/NewPipe
@Override
public void onPlaying() {
super.onPlaying();
updateStreamRelatedViews();
showAndAnimateControl(-1, true);
playbackSeekBar.setEnabled(true);
// Bug on lower api, disabling and enabling the seekBar resets the thumb color -.-, so sets the color again
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN)
playbackSeekBar.getThumb().setColorFilter(Color.RED, PorterDuff.Mode.SRC_IN);
loadingPanel.setVisibility(View.GONE);
animateView(currentDisplaySeek, AnimationUtils.Type.SCALE_AND_ALPHA, false, 200);
}
内容来源于网络,如有侵权,请联系作者删除!