Created
March 5, 2019 15:21
-
-
Save arnaud33200/cc38f59a1153f711cd0c09d67e908fd1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static PaintDrawable createTopBottomLinearGradientPaintDrawable(TwoColorGradient twoColorGradient, final float center) { | |
final int[] colors = | |
new int[]{twoColorGradient.getGradientStartColor(), twoColorGradient.getGradientEndColor()}; | |
ShaderFactory sf = new ShaderFactory() { | |
@Override | |
public Shader resize(int width, int height) { | |
float[] positions = new float[]{0.0f, center}; | |
return new LinearGradient(0, 0, 0, width, colors, positions, TileMode.CLAMP); | |
} | |
}; | |
PaintDrawable paintDrawable = new PaintDrawable(); | |
paintDrawable.setShape(new RectShape()); | |
paintDrawable.setShaderFactory(sf); | |
return paintDrawable; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment