use of android.graphics.drawable.GradientDrawable in project LshUtils by SenhLinsh.
the class LshColorDialog method setBgContent.
private void setBgContent(View view, int color) {
int dp10 = dp2px(10);
GradientDrawable bgContent = LshXmlCreater.createRectangleCorner(new float[] { dp10, dp10, dp10, dp10, 0, 0, 0, 0 }, color);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
view.setBackground(bgContent);
} else {
view.setBackgroundDrawable(bgContent);
}
}
use of android.graphics.drawable.GradientDrawable in project LshUtils by SenhLinsh.
the class LshXmlCreater method createRectangleCorner.
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public static GradientDrawable createRectangleCorner(float[] radii, ColorStateList color) {
GradientDrawable rectangleCorner = createRectangleCorner(radii);
rectangleCorner.setColor(color);
return rectangleCorner;
}
use of android.graphics.drawable.GradientDrawable in project LshUtils by SenhLinsh.
the class LshXmlCreater method createRectangleCorner.
public static GradientDrawable createRectangleCorner(float[] radii, int fillColor) {
GradientDrawable rectangleCorner = createRectangleCorner(radii);
rectangleCorner.setColor(fillColor);
return rectangleCorner;
}
use of android.graphics.drawable.GradientDrawable in project LshUtils by SenhLinsh.
the class LshXmlCreater method createRectangleShape.
public static GradientDrawable createRectangleShape(int fillColor) {
GradientDrawable gradientDrawable = createRectangleShape();
// 内部填充颜色
gradientDrawable.setColor(fillColor);
return gradientDrawable;
}
use of android.graphics.drawable.GradientDrawable in project Anki-Android by Ramblurr.
the class BarChart method drawBar.
/**
* Draws a bar.
*
* @param canvas the canvas
* @param xMin the X axis minimum
* @param yMin the Y axis minimum
* @param xMax the X axis maximum
* @param yMax the Y axis maximum
* @param scale the scale index
* @param seriesIndex the current series index
* @param paint the paint
*/
private void drawBar(Canvas canvas, float xMin, float yMin, float xMax, float yMax, int scale, int seriesIndex, Paint paint) {
SimpleSeriesRenderer renderer = mRenderer.getSeriesRendererAt(seriesIndex);
if (renderer.isGradientEnabled()) {
float minY = (float) toScreenPoint(new double[] { 0, renderer.getGradientStopValue() }, scale)[1];
float maxY = (float) toScreenPoint(new double[] { 0, renderer.getGradientStartValue() }, scale)[1];
float gradientMinY = Math.max(minY, yMin);
float gradientMaxY = Math.min(maxY, yMax);
int gradientMinColor = renderer.getGradientStopColor();
int gradientMaxColor = renderer.getGradientStartColor();
int gradientStartColor = gradientMaxColor;
int gradientStopColor = gradientMinColor;
if (yMin < minY) {
paint.setColor(gradientMinColor);
canvas.drawRect(Math.round(xMin), Math.round(yMin), Math.round(xMax), Math.round(gradientMinY), paint);
} else {
gradientStopColor = getGradientPartialColor(gradientMinColor, gradientMaxColor, (maxY - gradientMinY) / (maxY - minY));
}
if (yMax > maxY) {
paint.setColor(gradientMaxColor);
canvas.drawRect(Math.round(xMin), Math.round(gradientMaxY), Math.round(xMax), Math.round(yMax), paint);
} else {
gradientStartColor = getGradientPartialColor(gradientMaxColor, gradientMinColor, (gradientMaxY - minY) / (maxY - minY));
}
GradientDrawable gradient = new GradientDrawable(Orientation.BOTTOM_TOP, new int[] { gradientStartColor, gradientStopColor });
gradient.setBounds(Math.round(xMin), Math.round(gradientMinY), Math.round(xMax), Math.round(gradientMaxY));
gradient.draw(canvas);
} else {
if (Math.abs(yMin - yMax) < 1) {
if (yMin < yMax) {
yMax = yMin + 1;
} else {
yMax = yMin - 1;
}
}
canvas.drawRect(Math.round(xMin), Math.round(yMin), Math.round(xMax), Math.round(yMax), paint);
}
}
Aggregations