List of usage examples for android.graphics.drawable GradientDrawable setColorFilter
public void setColorFilter(@ColorInt int color, @NonNull PorterDuff.Mode mode)
From source file:com.pixby.texo.EditTools.ColorTool.java
private void drawBackground(View v) { int color = mSampleColors.get(v.getId()); LayerDrawable layerDrawable = (LayerDrawable) v.getBackground(); if (layerDrawable != null) { GradientDrawable shape = (GradientDrawable) layerDrawable.findDrawableByLayerId(R.id.color_fill); shape.setColorFilter(color, PorterDuff.Mode.MULTIPLY); shape = (GradientDrawable) layerDrawable.findDrawableByLayerId(R.id.color_focus); int alpha = v.hasFocus() ? 255 : 0; shape.setAlpha(alpha);/*from w ww . j a v a 2 s . c o m*/ } }