Search in sources :

Example 26 with OvalShape

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

the class FloatingActionButton method createDrawable.

private Drawable createDrawable(int color) {
    OvalShape ovalShape = new OvalShape();
    ShapeDrawable shapeDrawable = new ShapeDrawable(ovalShape);
    shapeDrawable.getPaint().setColor(color);
    if (mShadow && !hasLollipopApi()) {
        Drawable shadowDrawable = getResources().getDrawable(mType == TYPE_NORMAL ? R.drawable.fab_shadow : R.drawable.fab_shadow_mini);
        LayerDrawable layerDrawable = new LayerDrawable(new Drawable[] { shadowDrawable, shapeDrawable });
        layerDrawable.setLayerInset(1, mShadowSize, mShadowSize, mShadowSize, mShadowSize);
        return layerDrawable;
    } else {
        return shapeDrawable;
    }
}
Also used : LayerDrawable(android.graphics.drawable.LayerDrawable) LayerDrawable(android.graphics.drawable.LayerDrawable) Drawable(android.graphics.drawable.Drawable) StateListDrawable(android.graphics.drawable.StateListDrawable) ShapeDrawable(android.graphics.drawable.ShapeDrawable) RippleDrawable(android.graphics.drawable.RippleDrawable) ShapeDrawable(android.graphics.drawable.ShapeDrawable) OvalShape(android.graphics.drawable.shapes.OvalShape)

Example 27 with OvalShape

use of android.graphics.drawable.shapes.OvalShape in project Android-MaterialRefreshLayout by android-cjj.

the class CircleProgressBar method onLayout.

@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
    super.onLayout(changed, left, top, right, bottom);
    final float density = getContext().getResources().getDisplayMetrics().density;
    mDiameter = Math.min(getMeasuredWidth(), getMeasuredHeight());
    if (mDiameter <= 0) {
        mDiameter = (int) density * DEFAULT_CIRCLE_DIAMETER;
    }
    if (getBackground() == null && mCircleBackgroundEnabled) {
        final int shadowYOffset = (int) (density * Y_OFFSET);
        final int shadowXOffset = (int) (density * X_OFFSET);
        mShadowRadius = (int) (density * SHADOW_RADIUS);
        if (elevationSupported()) {
            mBgCircle = new ShapeDrawable(new OvalShape());
            ViewCompat.setElevation(this, SHADOW_ELEVATION * density);
        } else {
            OvalShape oval = new OvalShadow(mShadowRadius, mDiameter - mShadowRadius * 2);
            mBgCircle = new ShapeDrawable(oval);
            ViewCompat.setLayerType(this, ViewCompat.LAYER_TYPE_SOFTWARE, mBgCircle.getPaint());
            mBgCircle.getPaint().setShadowLayer(mShadowRadius, shadowXOffset, shadowYOffset, KEY_SHADOW_COLOR);
            final int padding = (int) mShadowRadius;
            // set padding so the inner image sits correctly within the shadow.
            setPadding(padding, padding, padding, padding);
        }
        mBgCircle.getPaint().setColor(mBackGroundColor);
        setBackgroundDrawable(mBgCircle);
    }
    mProgressDrawable.setBackgroundColor(mBackGroundColor);
    mProgressDrawable.setColorSchemeColors(mColors);
    mProgressDrawable.setSizeParameters(mDiameter, mDiameter, mInnerRadius <= 0 ? (mDiameter - mProgressStokeWidth * 2) / 4 : mInnerRadius, mProgressStokeWidth, mArrowWidth < 0 ? mProgressStokeWidth * 4 : mArrowWidth, mArrowHeight < 0 ? mProgressStokeWidth * 2 : mArrowHeight);
    if (isShowArrow()) {
        mProgressDrawable.showArrowOnFirstStart(true);
        mProgressDrawable.setArrowScale(1f);
        mProgressDrawable.showArrow(true);
    }
    super.setImageDrawable(null);
    super.setImageDrawable(mProgressDrawable);
    mProgressDrawable.setAlpha(255);
    if (getVisibility() == VISIBLE) {
        mProgressDrawable.setStartEndTrim(0, (float) 0.8);
    }
}
Also used : ShapeDrawable(android.graphics.drawable.ShapeDrawable) OvalShape(android.graphics.drawable.shapes.OvalShape) Paint(android.graphics.Paint)

Example 28 with OvalShape

use of android.graphics.drawable.shapes.OvalShape in project material-calendarview by prolificinteractive.

the class DayView method generateCircleDrawable.

private static Drawable generateCircleDrawable(final int color) {
    ShapeDrawable drawable = new ShapeDrawable(new OvalShape());
    drawable.getPaint().setColor(color);
    return drawable;
}
Also used : ShapeDrawable(android.graphics.drawable.ShapeDrawable) OvalShape(android.graphics.drawable.shapes.OvalShape)

Example 29 with OvalShape

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

Aggregations

OvalShape (android.graphics.drawable.shapes.OvalShape)44 ShapeDrawable (android.graphics.drawable.ShapeDrawable)40 Paint (android.graphics.Paint)17 SuppressLint (android.annotation.SuppressLint)10 StateListDrawable (android.graphics.drawable.StateListDrawable)8 ColorDrawable (android.graphics.drawable.ColorDrawable)7 LayerDrawable (android.graphics.drawable.LayerDrawable)7 Drawable (android.graphics.drawable.Drawable)5 ImageView (android.widget.ImageView)5 LinearGradient (android.graphics.LinearGradient)3 Shader (android.graphics.Shader)3 ShaderFactory (android.graphics.drawable.ShapeDrawable.ShaderFactory)3 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