Search in sources :

Example 91 with ShapeDrawable

use of android.graphics.drawable.ShapeDrawable in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class FloatingActionButton method createCircleDrawable.

private Drawable createCircleDrawable(int color, float strokeWidth) {
    int alpha = Color.alpha(color);
    int opaqueColor = opaque(color);
    ShapeDrawable fillDrawable = new ShapeDrawable(new OvalShape());
    final Paint paint = fillDrawable.getPaint();
    paint.setAntiAlias(true);
    paint.setColor(opaqueColor);
    Drawable[] layers = { fillDrawable, createInnerStrokesDrawable(opaqueColor, strokeWidth) };
    LayerDrawable drawable = alpha == 255 || !mStrokeVisible ? new LayerDrawable(layers) : new TranslucentLayerDrawable(alpha, layers);
    int halfStrokeWidth = (int) (strokeWidth / 2f);
    drawable.setLayerInset(1, halfStrokeWidth, halfStrokeWidth, halfStrokeWidth, halfStrokeWidth);
    return drawable;
}
Also used : LayerDrawable(android.graphics.drawable.LayerDrawable) LayerDrawable(android.graphics.drawable.LayerDrawable) ColorDrawable(android.graphics.drawable.ColorDrawable) Drawable(android.graphics.drawable.Drawable) StateListDrawable(android.graphics.drawable.StateListDrawable) ShapeDrawable(android.graphics.drawable.ShapeDrawable) ShapeDrawable(android.graphics.drawable.ShapeDrawable) Paint(android.graphics.Paint) OvalShape(android.graphics.drawable.shapes.OvalShape) SuppressLint(android.annotation.SuppressLint) Paint(android.graphics.Paint)

Example 92 with ShapeDrawable

use of android.graphics.drawable.ShapeDrawable in project coins-android by bubelov.

the class StaticClusterRenderer method makeClusterBackground.

private LayerDrawable makeClusterBackground() {
    mColoredCircleBackground = new ShapeDrawable(new OvalShape());
    ShapeDrawable outline = new ShapeDrawable(new OvalShape());
    // Transparent white.
    outline.getPaint().setColor(Color.WHITE);
    LayerDrawable background = new LayerDrawable(new Drawable[] { outline, mColoredCircleBackground });
    int strokeWidth = (int) (mDensity * 1.5f);
    background.setLayerInset(1, strokeWidth, strokeWidth, strokeWidth, strokeWidth);
    return background;
}
Also used : LayerDrawable(android.graphics.drawable.LayerDrawable) ShapeDrawable(android.graphics.drawable.ShapeDrawable) OvalShape(android.graphics.drawable.shapes.OvalShape) Point(com.google.maps.android.geometry.Point) SuppressLint(android.annotation.SuppressLint)

Example 93 with ShapeDrawable

use of android.graphics.drawable.ShapeDrawable in project MaterialAbout by jrvansuita.

the class RippleUtil method getRippleMask.

private static Drawable getRippleMask(int color) {
    float[] outerRadii = new float[8];
    // 3 is radius of final ripple,
    // instead of 3 you can give required final radius
    Arrays.fill(outerRadii, 3);
    RoundRectShape r = new RoundRectShape(outerRadii, 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 94 with ShapeDrawable

use of android.graphics.drawable.ShapeDrawable in project android_packages_apps_crDroidSettings by crdroidandroid.

the class ColorPickerPreference method createOvalShape.

private static ShapeDrawable createOvalShape(int size, int color) {
    ShapeDrawable shape = new ShapeDrawable(new OvalShape());
    shape.setIntrinsicHeight(size);
    shape.setIntrinsicWidth(size);
    shape.getPaint().setColor(color);
    return shape;
}
Also used : ShapeDrawable(android.graphics.drawable.ShapeDrawable) OvalShape(android.graphics.drawable.shapes.OvalShape)

Example 95 with ShapeDrawable

use of android.graphics.drawable.ShapeDrawable in project android_packages_apps_crDroidSettings by crdroidandroid.

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)96 OvalShape (android.graphics.drawable.shapes.OvalShape)44 Paint (android.graphics.Paint)32 Drawable (android.graphics.drawable.Drawable)24 LayerDrawable (android.graphics.drawable.LayerDrawable)24 StateListDrawable (android.graphics.drawable.StateListDrawable)17 SuppressLint (android.annotation.SuppressLint)16 ClipDrawable (android.graphics.drawable.ClipDrawable)16 Bitmap (android.graphics.Bitmap)15 BitmapDrawable (android.graphics.drawable.BitmapDrawable)15 BitmapShader (android.graphics.BitmapShader)14 RoundRectShape (android.graphics.drawable.shapes.RoundRectShape)14 AnimationDrawable (android.graphics.drawable.AnimationDrawable)13 ColorDrawable (android.graphics.drawable.ColorDrawable)9 RectShape (android.graphics.drawable.shapes.RectShape)8 Shape (android.graphics.drawable.shapes.Shape)7 Canvas (android.graphics.Canvas)6 Resources (android.content.res.Resources)5 Shader (android.graphics.Shader)5 TypedArray (android.content.res.TypedArray)4