Java Code Examples for android.graphics.PorterDuff.Mode#SRC_IN

The following examples show how to use android.graphics.PorterDuff.Mode#SRC_IN . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FloatingActionButton.java    From material-components-android with Apache License 2.0 6 votes vote down vote up
private void onApplySupportImageTint() {
  Drawable drawable = getDrawable();
  if (drawable == null) {
    return;
  }

  if (imageTint == null) {
    DrawableCompat.clearColorFilter(drawable);
    return;
  }

  int color = imageTint.getColorForState(getDrawableState(), Color.TRANSPARENT);
  Mode mode = imageMode;
  if (mode == null) {
    mode = Mode.SRC_IN;
  }

  drawable
      .mutate()
      .setColorFilter(AppCompatDrawableManager.getPorterDuffColorFilter(color, mode));
}
 
Example 2
Source File: RcRollerView.java    From FimiX8-RE with MIT License 5 votes vote down vote up
private void init() {
    this.paint = new Paint();
    this.paint.setAntiAlias(true);
    this.paint.setStyle(Style.FILL);
    this.paint.setDither(true);
    this.paint.setFilterBitmap(true);
    this.xfermode = new PorterDuffXfermode(Mode.SRC_IN);
}
 
Example 3
Source File: SeekBar.java    From AndroidMaterialPreferences with Apache License 2.0 5 votes vote down vote up
/**
 * Sets the color of the seek bar.
 *
 * @param color
 *         The color, which should be set as an {@link Integer} value
 */
public final void setSeekBarColor(@ColorInt final int color) {
    this.seekBarColor = color;
    ColorFilter colorFilter = new PorterDuffColorFilter(color, Mode.SRC_IN);
    getProgressDrawable().setColorFilter(colorFilter);
    getThumbDrawable().setColorFilter(colorFilter);
}
 
Example 4
Source File: Tools.java    From AndroidAnimationExercise with Apache License 2.0 4 votes vote down vote up
public static PorterDuff.Mode intToMode(int val) {
    switch (val) {
        default:
        case 0:
            return Mode.CLEAR;
        case 1:
            return Mode.SRC;
        case 2:
            return Mode.DST;
        case 3:
            return Mode.SRC_OVER;
        case 4:
            return Mode.DST_OVER;
        case 5:
            return Mode.SRC_IN;
        case 6:
            return Mode.DST_IN;
        case 7:
            return Mode.SRC_OUT;
        case 8:
            return Mode.DST_OUT;
        case 9:
            return Mode.SRC_ATOP;
        case 10:
            return Mode.DST_ATOP;
        case 11:
            return Mode.XOR;
        case 16:
            return Mode.DARKEN;
        case 17:
            return Mode.LIGHTEN;
        case 13:
            return Mode.MULTIPLY;
        case 14:
            return Mode.SCREEN;
        case 12:
            return Mode.ADD;
        case 15:
            return Mode.OVERLAY;
    }
}