Search in sources :

Example 6 with OvalShape

use of android.graphics.drawable.shapes.OvalShape in project android-PullRefreshLayout by baoyongzhang.

the class MaterialDrawable method createCircleDrawable.

private void createCircleDrawable() {
    float radius = CIRCLE_DIAMETER / 2;
    final float density = getContext().getResources().getDisplayMetrics().density;
    final int diameter = (int) (radius * density * 2);
    final int shadowYOffset = (int) (density * Y_OFFSET);
    final int shadowXOffset = (int) (density * X_OFFSET);
    mShadowRadius = (int) (density * SHADOW_RADIUS);
    OvalShape oval = new OvalShadow(mShadowRadius, diameter);
    mCircle = new ShapeDrawable(oval);
    //        ViewCompat.setLayerType(this, ViewCompat.LAYER_TYPE_SOFTWARE, circle.getPaint());
    mCircle.getPaint().setShadowLayer(mShadowRadius, shadowXOffset, shadowYOffset, KEY_SHADOW_COLOR);
    mPadding = (int) mShadowRadius;
    mCircle.getPaint().setColor(Color.WHITE);
}
Also used : ShapeDrawable(android.graphics.drawable.ShapeDrawable) OvalShape(android.graphics.drawable.shapes.OvalShape) Paint(android.graphics.Paint)

Example 7 with OvalShape

use of android.graphics.drawable.shapes.OvalShape in project Space-Navigation-View by armcha.

the class BadgeHelper method makeShapeDrawable.

/**
     * Make circle drawable for badge background
     *
     * @param color background color
     * @return return colored circle drawable
     */
static ShapeDrawable makeShapeDrawable(int color) {
    ShapeDrawable badgeBackground = new ShapeDrawable(new OvalShape());
    badgeBackground.setIntrinsicWidth(10);
    badgeBackground.setIntrinsicHeight(10);
    badgeBackground.getPaint().setColor(color);
    return badgeBackground;
}
Also used : ShapeDrawable(android.graphics.drawable.ShapeDrawable) OvalShape(android.graphics.drawable.shapes.OvalShape)

Example 8 with OvalShape

use of android.graphics.drawable.shapes.OvalShape in project coursera-android by aporter.

the class ShapeDrawActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    int width = (int) getResources().getDimension(R.dimen.image_width);
    int height = (int) getResources().getDimension(R.dimen.image_height);
    int padding = (int) getResources().getDimension(R.dimen.padding);
    // Get container View
    RelativeLayout rl = (RelativeLayout) findViewById(R.id.main_window);
    // Create Cyan Shape
    ShapeDrawable cyanShape = new ShapeDrawable(new OvalShape());
    cyanShape.getPaint().setColor(Color.CYAN);
    cyanShape.setIntrinsicHeight(height);
    cyanShape.setIntrinsicWidth(width);
    cyanShape.setAlpha(alpha);
    // Put Cyan Shape into an ImageView
    ImageView cyanView = new ImageView(getApplicationContext());
    cyanView.setImageDrawable(cyanShape);
    cyanView.setPadding(padding, padding, padding, padding);
    // Specify placement of ImageView within RelativeLayout
    RelativeLayout.LayoutParams cyanViewLayoutParams = new RelativeLayout.LayoutParams(height, width);
    cyanViewLayoutParams.addRule(RelativeLayout.CENTER_VERTICAL);
    cyanViewLayoutParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
    cyanView.setLayoutParams(cyanViewLayoutParams);
    rl.addView(cyanView);
    // Create Magenta Shape
    ShapeDrawable magentaShape = new ShapeDrawable(new OvalShape());
    magentaShape.getPaint().setColor(Color.MAGENTA);
    magentaShape.setIntrinsicHeight(height);
    magentaShape.setIntrinsicWidth(width);
    magentaShape.setAlpha(alpha);
    // Put Magenta Shape into an ImageView
    ImageView magentaView = new ImageView(getApplicationContext());
    magentaView.setImageDrawable(magentaShape);
    magentaView.setPadding(padding, padding, padding, padding);
    // Specify placement of ImageView within RelativeLayout
    RelativeLayout.LayoutParams magentaViewLayoutParams = new RelativeLayout.LayoutParams(height, width);
    magentaViewLayoutParams.addRule(RelativeLayout.CENTER_VERTICAL);
    magentaViewLayoutParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
    magentaView.setLayoutParams(magentaViewLayoutParams);
    rl.addView(magentaView);
}
Also used : RelativeLayout(android.widget.RelativeLayout) ShapeDrawable(android.graphics.drawable.ShapeDrawable) ImageView(android.widget.ImageView) OvalShape(android.graphics.drawable.shapes.OvalShape)

Example 9 with OvalShape

use of android.graphics.drawable.shapes.OvalShape in project android-floating-action-button by futuresimple.

the class FloatingActionButton method createOuterStrokeDrawable.

private Drawable createOuterStrokeDrawable(float strokeWidth) {
    ShapeDrawable shapeDrawable = new ShapeDrawable(new OvalShape());
    final Paint paint = shapeDrawable.getPaint();
    paint.setAntiAlias(true);
    paint.setStrokeWidth(strokeWidth);
    paint.setStyle(Style.STROKE);
    paint.setColor(Color.BLACK);
    paint.setAlpha(opacityToAlpha(0.02f));
    return shapeDrawable;
}
Also used : ShapeDrawable(android.graphics.drawable.ShapeDrawable) Paint(android.graphics.Paint) OvalShape(android.graphics.drawable.shapes.OvalShape)

Example 10 with OvalShape

use of android.graphics.drawable.shapes.OvalShape in project android-floating-action-button by futuresimple.

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)

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