Search in sources :

Example 61 with ShapeDrawable

use of android.graphics.drawable.ShapeDrawable in project android-maps-utils by googlemaps.

the class DefaultClusterRenderer method makeClusterBackground.

private LayerDrawable makeClusterBackground() {
    mColoredCircleBackground = new ShapeDrawable(new OvalShape());
    ShapeDrawable outline = new ShapeDrawable(new OvalShape());
    // Transparent white.
    outline.getPaint().setColor(0x80ffffff);
    LayerDrawable background = new LayerDrawable(new Drawable[] { outline, mColoredCircleBackground });
    int strokeWidth = (int) (mDensity * 3);
    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 62 with ShapeDrawable

use of android.graphics.drawable.ShapeDrawable in project StylishMusicPlayer by ryanhoo.

the class AlbumImageView method init.

private void init() {
    mDensity = getContext().getResources().getDisplayMetrics().density;
    final int shadowXOffset = (int) (mDensity * X_OFFSET);
    final int shadowYOffset = (int) (mDensity * Y_OFFSET);
    mShadowRadius = (int) (mDensity * SHADOW_RADIUS);
    ShapeDrawable circle;
    if (elevationSupported()) {
        circle = new ShapeDrawable(new OvalShape());
        ViewCompat.setElevation(this, SHADOW_ELEVATION * mDensity);
    } else {
        OvalShape oval = new OvalShadow(mShadowRadius);
        circle = new ShapeDrawable(oval);
        ViewCompat.setLayerType(this, ViewCompat.LAYER_TYPE_SOFTWARE, circle.getPaint());
        circle.getPaint().setShadowLayer(mShadowRadius, shadowXOffset, shadowYOffset, KEY_SHADOW_COLOR);
        final int padding = mShadowRadius;
        // set padding so the inner image sits correctly within the shadow.
        setPadding(padding, padding, padding, padding);
    }
    circle.getPaint().setAntiAlias(true);
    circle.getPaint().setColor(DEFAULT_ALBUM_COLOR);
    setBackground(circle);
    mPaint.setAntiAlias(true);
    mPaint.setTextAlign(Paint.Align.CENTER);
    mPaint.setStyle(Paint.Style.FILL);
    mPaint.setColor(DEFAULT_ALBUM_COLOR);
    mPaint.setTextSize(ALBUM_CIRCLE_TEXT_SIZE * mDensity);
    mRotateAnimator = ObjectAnimator.ofFloat(this, "rotation", 0f, 360f);
    mRotateAnimator.setDuration(3600);
    mRotateAnimator.setInterpolator(new LinearInterpolator());
    mRotateAnimator.setRepeatMode(ValueAnimator.RESTART);
    mRotateAnimator.setRepeatCount(ValueAnimator.INFINITE);
}
Also used : LinearInterpolator(android.view.animation.LinearInterpolator) ShapeDrawable(android.graphics.drawable.ShapeDrawable) OvalShape(android.graphics.drawable.shapes.OvalShape) SuppressLint(android.annotation.SuppressLint)

Example 63 with ShapeDrawable

use of android.graphics.drawable.ShapeDrawable in project StylishMusicPlayer by ryanhoo.

the class ShadowImageView method init.

private void init() {
    final float density = getContext().getResources().getDisplayMetrics().density;
    final int shadowXOffset = (int) (density * X_OFFSET);
    final int shadowYOffset = (int) (density * Y_OFFSET);
    mShadowRadius = (int) (density * SHADOW_RADIUS);
    ShapeDrawable circle;
    if (elevationSupported()) {
        circle = new ShapeDrawable(new OvalShape());
        ViewCompat.setElevation(this, SHADOW_ELEVATION * density);
    } else {
        OvalShape oval = new OvalShadow(mShadowRadius);
        circle = new ShapeDrawable(oval);
        ViewCompat.setLayerType(this, ViewCompat.LAYER_TYPE_SOFTWARE, circle.getPaint());
        circle.getPaint().setShadowLayer(mShadowRadius, shadowXOffset, shadowYOffset, KEY_SHADOW_COLOR);
        final int padding = mShadowRadius;
        // set padding so the inner image sits correctly within the shadow.
        setPadding(padding, padding, padding, padding);
    }
    circle.getPaint().setAntiAlias(true);
    circle.getPaint().setColor(DEFAULT_BACKGROUND_COLOR);
    setBackground(circle);
    mRotateAnimator = ObjectAnimator.ofFloat(this, "rotation", 0f, 360f);
    mRotateAnimator.setDuration(7200);
    mRotateAnimator.setInterpolator(new LinearInterpolator());
    mRotateAnimator.setRepeatMode(ValueAnimator.RESTART);
    mRotateAnimator.setRepeatCount(ValueAnimator.INFINITE);
}
Also used : LinearInterpolator(android.view.animation.LinearInterpolator) ShapeDrawable(android.graphics.drawable.ShapeDrawable) OvalShape(android.graphics.drawable.shapes.OvalShape)

Example 64 with ShapeDrawable

use of android.graphics.drawable.ShapeDrawable in project Euclid by Yalantis.

the class EuclidActivity method buildAvatarCircleOverlay.

/**
     * This method creates a view with empty/transparent circle in it's center. This view is used
     * to cover the profile avatar.
     *
     * @return - ShapeDrawable object.
     */
private ShapeDrawable buildAvatarCircleOverlay() {
    int radius = 666;
    ShapeDrawable overlay = new ShapeDrawable(new RoundRectShape(null, new RectF(sScreenWidth / 2 - dpToPx(getCircleRadiusDp() * 2), sProfileImageHeight / 2 - dpToPx(getCircleRadiusDp() * 2), sScreenWidth / 2 - dpToPx(getCircleRadiusDp() * 2), sProfileImageHeight / 2 - dpToPx(getCircleRadiusDp() * 2)), new float[] { radius, radius, radius, radius, radius, radius, radius, radius }));
    overlay.getPaint().setColor(getResources().getColor(R.color.gray));
    return overlay;
}
Also used : RoundRectShape(android.graphics.drawable.shapes.RoundRectShape) RectF(android.graphics.RectF) ShapeDrawable(android.graphics.drawable.ShapeDrawable)

Example 65 with ShapeDrawable

use of android.graphics.drawable.ShapeDrawable in project material-dialogs by afollestad.

the class CircleView method createSelector.

private Drawable createSelector(int color) {
    ShapeDrawable darkerCircle = new ShapeDrawable(new OvalShape());
    darkerCircle.getPaint().setColor(translucentColor(shiftColorUp(color)));
    StateListDrawable stateListDrawable = new StateListDrawable();
    stateListDrawable.addState(new int[] { android.R.attr.state_pressed }, darkerCircle);
    return stateListDrawable;
}
Also used : ShapeDrawable(android.graphics.drawable.ShapeDrawable) OvalShape(android.graphics.drawable.shapes.OvalShape) StateListDrawable(android.graphics.drawable.StateListDrawable)

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