Search in sources :

Example 41 with GradientDrawable

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);
    }
}
Also used : GradientDrawable(android.graphics.drawable.GradientDrawable)

Example 42 with GradientDrawable

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;
}
Also used : GradientDrawable(android.graphics.drawable.GradientDrawable) TargetApi(android.annotation.TargetApi)

Example 43 with GradientDrawable

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;
}
Also used : GradientDrawable(android.graphics.drawable.GradientDrawable)

Example 44 with GradientDrawable

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;
}
Also used : GradientDrawable(android.graphics.drawable.GradientDrawable)

Example 45 with 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);
    }
}
Also used : SimpleSeriesRenderer(org.achartengine.renderer.SimpleSeriesRenderer) Paint(android.graphics.Paint) GradientDrawable(android.graphics.drawable.GradientDrawable)

Aggregations

GradientDrawable (android.graphics.drawable.GradientDrawable)169 Paint (android.graphics.Paint)19 Drawable (android.graphics.drawable.Drawable)19 StateListDrawable (android.graphics.drawable.StateListDrawable)19 View (android.view.View)19 SuppressLint (android.annotation.SuppressLint)18 TextView (android.widget.TextView)18 LayerDrawable (android.graphics.drawable.LayerDrawable)16 ImageView (android.widget.ImageView)14 LinearLayout (android.widget.LinearLayout)12 TypedArray (android.content.res.TypedArray)8 FrameLayout (android.widget.FrameLayout)6 TimeAnimator (android.animation.TimeAnimator)5 Typeface (android.graphics.Typeface)5 LayoutInflater (android.view.LayoutInflater)5 ViewGroup (android.view.ViewGroup)5 Attributes (com.cengalabs.flatui.Attributes)5 Resources (android.content.res.Resources)4 TextPaint (android.text.TextPaint)4 Button (android.widget.Button)4