Example usage for android.graphics.drawable GradientDrawable setDither

List of usage examples for android.graphics.drawable GradientDrawable setDither

Introduction

In this page you can find the example usage for android.graphics.drawable GradientDrawable setDither.

Prototype

@Override
    public void setDither(boolean dither) 

Source Link

Usage

From source file:Main.java

public static synchronized GradientDrawable getHorizontalGradiant(final int color, final int backgroundColor) {
    final int[] colors = new int[2];
    colors[0] = backgroundColor;/*ww  w.  j av  a2s.  co m*/
    colors[1] = color;

    final GradientDrawable d = new GradientDrawable(GradientDrawable.Orientation.BOTTOM_TOP, colors);
    d.setDither(true);

    return d;
}

From source file:Main.java

public static synchronized GradientDrawable getGradiant(final int color) {
    int[] colors;
    int darkerColor;
    // Get darker color
    final float[] hsv = new float[3];
    Color.colorToHSV(color, hsv);
    hsv[2] *= 0.9f; // value component
    darkerColor = Color.HSVToColor(hsv);

    colors = new int[2];
    colors[0] = darkerColor;/*from   www . j  av a 2s.c  o m*/
    colors[1] = color;

    final GradientDrawable d = new GradientDrawable(GradientDrawable.Orientation.BOTTOM_TOP, colors);
    d.setDither(true);

    return d;
}

From source file:Main.java

public static void setGradientForPreferenceView(View v) {

    int[] colorsForGradient = new int[2];
    colorsForGradient[0] = Color.argb(0, 0, 0, 0);
    colorsForGradient[1] = Color.argb(64, 255, 255, 255);
    GradientDrawable d = new GradientDrawable(GradientDrawable.Orientation.LEFT_RIGHT, colorsForGradient);
    d.setGradientType(GradientDrawable.LINEAR_GRADIENT);
    d.setShape(GradientDrawable.RECTANGLE);
    // doesn't help d.setUseLevel(true);
    d.setDither(true);
    v.setBackgroundDrawable(d);//from   ww  w.  j av  a 2  s . c  om
}

From source file:com.bilibili.magicasakura.utils.GradientDrawableUtils.java

void inflateGradientRootElement(Context context, AttributeSet attrs, GradientDrawable gradientDrawable) {
    int shape = getAttrInt(context, attrs, android.R.attr.shape, GradientDrawable.RECTANGLE);
    gradientDrawable.setShape(shape);/*from  w  w  w. j a  v a2  s  . c  om*/
    boolean dither = getAttrBoolean(context, attrs, android.R.attr.dither, false);
    gradientDrawable.setDither(dither);
}

From source file:com.bilibili.magicasakura.utils.GradientDrawableInflateImpl.java

void inflateGradientRootElement(Context context, AttributeSet attrs, GradientDrawable gradientDrawable) {
    int shape = DrawableUtils.getAttrInt(context, attrs, android.R.attr.shape, GradientDrawable.RECTANGLE);
    gradientDrawable.setShape(shape);/*www  . j  a  v  a2  s .  co m*/
    boolean dither = DrawableUtils.getAttrBoolean(context, attrs, android.R.attr.dither, false);
    gradientDrawable.setDither(dither);
}