Search in sources :

Example 1 with ShapeDrawable

use of android.graphics.drawable.ShapeDrawable in project FastAdapter by mikepenz.

the class FastAdapterUIUtils method getRippleMask.

/**
     * helper to create an ripple mask with the given color and radius
     *
     * @param color  the color
     * @param radius the radius
     * @return the mask drawable
     */
private static Drawable getRippleMask(int color, int radius) {
    float[] outerRadius = new float[8];
    Arrays.fill(outerRadius, radius);
    RoundRectShape r = new RoundRectShape(outerRadius, null, null);
    ShapeDrawable shapeDrawable = new ShapeDrawable(r);
    shapeDrawable.getPaint().setColor(color);
    return shapeDrawable;
}
Also used : RoundRectShape(android.graphics.drawable.shapes.RoundRectShape) ShapeDrawable(android.graphics.drawable.ShapeDrawable)

Example 2 with ShapeDrawable

use of android.graphics.drawable.ShapeDrawable in project actor-platform by actorapp.

the class ShareMenuButtonFactory method get.

public static StateListDrawable get(int color, Context context) {
    ShapeDrawable bg = new ShapeDrawable(new OvalShape());
    int padding = Screen.dp(5);
    bg.getPaint().setColor(color);
    ShapeDrawable bgPressed = new ShapeDrawable(new OvalShape());
    bgPressed.getPaint().setColor(ActorStyle.getDarkenArgb(color, 0.95));
    StateListDrawable states = new StateListDrawable();
    states.addState(new int[] { android.R.attr.state_pressed }, new InsetDrawable(bgPressed, padding));
    states.addState(StateSet.WILD_CARD, new InsetDrawable(bg, padding));
    return states;
}
Also used : ShapeDrawable(android.graphics.drawable.ShapeDrawable) InsetDrawable(android.graphics.drawable.InsetDrawable) OvalShape(android.graphics.drawable.shapes.OvalShape) StateListDrawable(android.graphics.drawable.StateListDrawable)

Example 3 with ShapeDrawable

use of android.graphics.drawable.ShapeDrawable in project android_frameworks_base by ParanoidAndroid.

the class PlaybackGraphs method drawVerticalShiftedShapes.

public void drawVerticalShiftedShapes(Canvas canvas, ArrayList<ShapeDrawable> shapes) {
    // Shapes drawn here are drawn relative to the viewRect
    Rect viewRect = shapes.get(shapes.size() - 1).getBounds();
    canvas.translate(0, 5 * PlaybackView.TILE_SCALE - viewRect.top);
    for (ShapeDrawable shape : mShapes) {
        shape.draw(canvas);
    }
    for (ShapeDrawable shape : shapes) {
        shape.draw(canvas);
    }
}
Also used : Rect(android.graphics.Rect) ShapeDrawable(android.graphics.drawable.ShapeDrawable)

Example 4 with ShapeDrawable

use of android.graphics.drawable.ShapeDrawable in project AndroidDevelop by 7449.

the class BadgeView method getDefaultBackground.

private ShapeDrawable getDefaultBackground() {
    int r = dipToPixels(DEFAULT_CORNER_RADIUS_DIP);
    float[] outerR = new float[] { r, r, r, r, r, r, r, r };
    RoundRectShape rr = new RoundRectShape(outerR, null, null);
    ShapeDrawable drawable = new ShapeDrawable(rr);
    drawable.getPaint().setColor(badgeColor);
    return drawable;
}
Also used : RoundRectShape(android.graphics.drawable.shapes.RoundRectShape) ShapeDrawable(android.graphics.drawable.ShapeDrawable) SuppressLint(android.annotation.SuppressLint)

Example 5 with ShapeDrawable

use of android.graphics.drawable.ShapeDrawable in project UltimateAndroid by cymcsg.

the class AddFloatingActionButton method getIconDrawable.

@Override
Drawable getIconDrawable() {
    final float iconSize = getDimension(R.dimen.fab_icon_size);
    final float iconHalfSize = iconSize / 2f;
    final float plusSize = getDimension(R.dimen.fab_plus_icon_size);
    final float plusHalfStroke = getDimension(R.dimen.fab_plus_icon_stroke) / 2f;
    final float plusOffset = (iconSize - plusSize) / 2f;
    final Shape shape = new Shape() {

        @Override
        public void draw(Canvas canvas, Paint paint) {
            canvas.drawRect(plusOffset, iconHalfSize - plusHalfStroke, iconSize - plusOffset, iconHalfSize + plusHalfStroke, paint);
            canvas.drawRect(iconHalfSize - plusHalfStroke, plusOffset, iconHalfSize + plusHalfStroke, iconSize - plusOffset, paint);
        }
    };
    ShapeDrawable drawable = new ShapeDrawable(shape);
    final Paint paint = drawable.getPaint();
    paint.setColor(mPlusColor);
    paint.setStyle(Style.FILL);
    paint.setAntiAlias(true);
    return drawable;
}
Also used : Shape(android.graphics.drawable.shapes.Shape) Canvas(android.graphics.Canvas) ShapeDrawable(android.graphics.drawable.ShapeDrawable) Paint(android.graphics.Paint)

Aggregations

ShapeDrawable (android.graphics.drawable.ShapeDrawable)133 OvalShape (android.graphics.drawable.shapes.OvalShape)66 Paint (android.graphics.Paint)38 Drawable (android.graphics.drawable.Drawable)30 LayerDrawable (android.graphics.drawable.LayerDrawable)28 SuppressLint (android.annotation.SuppressLint)20 RoundRectShape (android.graphics.drawable.shapes.RoundRectShape)20 StateListDrawable (android.graphics.drawable.StateListDrawable)18 ClipDrawable (android.graphics.drawable.ClipDrawable)17 Bitmap (android.graphics.Bitmap)16 BitmapDrawable (android.graphics.drawable.BitmapDrawable)16 BitmapShader (android.graphics.BitmapShader)15 AnimationDrawable (android.graphics.drawable.AnimationDrawable)14 ColorDrawable (android.graphics.drawable.ColorDrawable)12 RectShape (android.graphics.drawable.shapes.RectShape)10 Resources (android.content.res.Resources)8 Shape (android.graphics.drawable.shapes.Shape)8 ImageView (android.widget.ImageView)7 Canvas (android.graphics.Canvas)6 Shader (android.graphics.Shader)6