Search in sources :

Example 31 with OvalShape

use of android.graphics.drawable.shapes.OvalShape 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 32 with OvalShape

use of android.graphics.drawable.shapes.OvalShape 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)

Example 33 with OvalShape

use of android.graphics.drawable.shapes.OvalShape in project SublimePicker by vikramkakkar.

the class SUtils method createImageViewShape.

// Base icon bg shape
private static Drawable createImageViewShape(int color) {
    OvalShape ovalShape = new OvalShape();
    ShapeDrawable shapeDrawable = new ShapeDrawable(ovalShape);
    shapeDrawable.getPaint().setColor(color);
    return shapeDrawable;
}
Also used : ShapeDrawable(android.graphics.drawable.ShapeDrawable) OvalShape(android.graphics.drawable.shapes.OvalShape)

Example 34 with OvalShape

use of android.graphics.drawable.shapes.OvalShape in project AndroidChromium by JackyAndroid.

the class DownloadNotificationService method getLargeNotificationIcon.

private Bitmap getLargeNotificationIcon(Bitmap bitmap) {
    Resources resources = mContext.getResources();
    int height = (int) resources.getDimension(android.R.dimen.notification_large_icon_height);
    int width = (int) resources.getDimension(android.R.dimen.notification_large_icon_width);
    final OvalShape circle = new OvalShape();
    circle.resize(width, height);
    final Paint paint = new Paint();
    paint.setColor(ApiCompatibilityUtils.getColor(resources, R.color.google_blue_grey_500));
    final Bitmap result = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
    Canvas canvas = new Canvas(result);
    circle.draw(canvas, paint);
    float leftOffset = (width - bitmap.getWidth()) / 2f;
    float topOffset = (height - bitmap.getHeight()) / 2f;
    if (leftOffset >= 0 && topOffset >= 0) {
        canvas.drawBitmap(bitmap, leftOffset, topOffset, null);
    } else {
        // Scale down the icon into the notification icon dimensions
        canvas.drawBitmap(bitmap, new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight()), new Rect(0, 0, width, height), null);
    }
    return result;
}
Also used : Bitmap(android.graphics.Bitmap) Rect(android.graphics.Rect) Canvas(android.graphics.Canvas) Resources(android.content.res.Resources) Paint(android.graphics.Paint) OvalShape(android.graphics.drawable.shapes.OvalShape) Paint(android.graphics.Paint)

Example 35 with OvalShape

use of android.graphics.drawable.shapes.OvalShape in project FloatingActionButton by Clans.

the class FloatingActionButton method createCircleDrawable.

private Drawable createCircleDrawable(int color) {
    CircleDrawable shapeDrawable = new CircleDrawable(new OvalShape());
    shapeDrawable.getPaint().setColor(color);
    return shapeDrawable;
}
Also used : OvalShape(android.graphics.drawable.shapes.OvalShape)

Aggregations

OvalShape (android.graphics.drawable.shapes.OvalShape)48 ShapeDrawable (android.graphics.drawable.ShapeDrawable)44 Paint (android.graphics.Paint)20 SuppressLint (android.annotation.SuppressLint)12 ColorDrawable (android.graphics.drawable.ColorDrawable)9 StateListDrawable (android.graphics.drawable.StateListDrawable)9 LayerDrawable (android.graphics.drawable.LayerDrawable)8 Drawable (android.graphics.drawable.Drawable)6 ImageView (android.widget.ImageView)5 LinearGradient (android.graphics.LinearGradient)4 Shader (android.graphics.Shader)4 ShaderFactory (android.graphics.drawable.ShapeDrawable.ShaderFactory)4 View (android.view.View)3 Bitmap (android.graphics.Bitmap)2 Rect (android.graphics.Rect)2 RectF (android.graphics.RectF)2 RoundRectShape (android.graphics.drawable.shapes.RoundRectShape)2 FloatingActionButton (android.support.design.widget.FloatingActionButton)2 LinearInterpolator (android.view.animation.LinearInterpolator)2 RelativeLayout (android.widget.RelativeLayout)2