Search in sources :

Example 1 with OvalShape

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

use of android.graphics.drawable.shapes.OvalShape in project ImageWindow by kanytu.

the class ImageWindow method init.

private void init() {
    ImageView closeButton = new ImageView(getContext());
    closeButton.setLayoutParams(new RelativeLayout.LayoutParams((int) (mCloseButtonSize), (int) (mCloseButtonSize)));
    StateListDrawable drawable = new StateListDrawable();
    ShapeDrawable shape = new ShapeDrawable(new OvalShape());
    ShapeDrawable shapePressed = new ShapeDrawable(new OvalShape());
    shape.setColorFilter(mCloseColor, PorterDuff.Mode.SRC_ATOP);
    //a little bit darker
    shapePressed.setColorFilter(mCloseColor - 0x444444, PorterDuff.Mode.SRC_ATOP);
    drawable.addState(new int[] { android.R.attr.state_pressed }, shapePressed);
    drawable.addState(new int[] {}, shape);
    closeButton.setImageResource(mCloseIcon);
    //todo change this to support lower api
    closeButton.setBackground(drawable);
    closeButton.setClickable(true);
    closeButton.setId(R.id.closeId);
    mImageView = new CustomImageView(getContext(), mCloseButtonSize, mCloseButtonMargin, mCornerRadius);
    RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    params.setMargins(Math.round(mTopLeftMargin), Math.round(mTopLeftMargin), 0, 0);
    mImageView.setLayoutParams(params);
    mImageView.setAdjustViewBounds(true);
    addView(mImageView);
    addView(closeButton);
}
Also used : RelativeLayout(android.widget.RelativeLayout) ShapeDrawable(android.graphics.drawable.ShapeDrawable) ImageView(android.widget.ImageView) StateListDrawable(android.graphics.drawable.StateListDrawable) OvalShape(android.graphics.drawable.shapes.OvalShape)

Example 3 with OvalShape

use of android.graphics.drawable.shapes.OvalShape in project FlyRefresh by race604.

the class PullHeaderLayout method setActionDrawable.

public void setActionDrawable(Drawable actionDrawable) {
    mActionDrawable = actionDrawable;
    if (mActionDrawable != null) {
        if (mActionView == null) {
            final int bgColor = UIUtils.getThemeColorFromAttrOrRes(getContext(), R.attr.colorAccent, R.color.accent);
            final int pressedColor = UIUtils.darkerColor(bgColor, 0.8f);
            final ShapeDrawable bgDrawable = new ShapeDrawable(new OvalShape());
            bgDrawable.getPaint().setColor(bgColor);
            mActionView = new FloatingActionButton(getContext());
            mActionView.setRippleColor(pressedColor);
            mActionView.setBackgroundDrawable(bgDrawable);
            addView(mActionView, new LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
        }
        if (mFlyView == null) {
            mFlyView = new ImageView(getContext());
            mFlyView.setScaleType(ImageView.ScaleType.FIT_XY);
            addView(mFlyView, new LayoutParams(ACTION_ICON_SIZE, ACTION_ICON_SIZE));
            mFlyView.bringToFront();
            float elevation = ViewCompat.getElevation(mActionView);
            ViewCompat.setElevation(mFlyView, elevation + 1);
        }
        mFlyView.setImageDrawable(mActionDrawable);
    } else {
        if (mActionView != null) {
            removeView(mActionView);
            removeView(mFlyView);
            mActionView = null;
            mFlyView = null;
        }
    }
}
Also used : ShapeDrawable(android.graphics.drawable.ShapeDrawable) FloatingActionButton(android.support.design.widget.FloatingActionButton) ImageView(android.widget.ImageView) OvalShape(android.graphics.drawable.shapes.OvalShape)

Example 4 with OvalShape

use of android.graphics.drawable.shapes.OvalShape in project BottomBar by roughike.

the class BadgeCircle method make.

/**
     * Creates a new circle for the Badge background.
     *
     * @param size  the width and height for the circle
     * @param color the activeIconColor for the circle
     * @return a nice and adorable circle.
     */
static ShapeDrawable make(int size, int color) {
    ShapeDrawable indicator = new ShapeDrawable(new OvalShape());
    indicator.setIntrinsicWidth(size);
    indicator.setIntrinsicHeight(size);
    indicator.getPaint().setColor(color);
    return indicator;
}
Also used : ShapeDrawable(android.graphics.drawable.ShapeDrawable) OvalShape(android.graphics.drawable.shapes.OvalShape)

Example 5 with OvalShape

use of android.graphics.drawable.shapes.OvalShape in project android-Ultra-Pull-To-Refresh by liaohuqiu.

the class MaterialProgressDrawable method setUp.

private void setUp(final double diameter) {
    PtrLocalDisplay.init(mParent.getContext());
    final int shadowYOffset = PtrLocalDisplay.dp2px(Y_OFFSET);
    final int shadowXOffset = PtrLocalDisplay.dp2px(X_OFFSET);
    int mShadowRadius = PtrLocalDisplay.dp2px(SHADOW_RADIUS);
    OvalShape oval = new OvalShadow(mShadowRadius, (int) diameter);
    mShadow = new ShapeDrawable(oval);
    if (Build.VERSION.SDK_INT >= 11) {
        mParent.setLayerType(View.LAYER_TYPE_SOFTWARE, mShadow.getPaint());
    }
    mShadow.getPaint().setShadowLayer(mShadowRadius, shadowXOffset, shadowYOffset, KEY_SHADOW_COLOR);
}
Also used : 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