Search in sources :

Example 1 with Shape

use of android.graphics.drawable.shapes.Shape in project UltimateRecyclerView by cymcsg.

the class AddFloatingActionButton method getIconDrawable.

/**
     * generate the PLUS sign
     *
     * @return the drawable product
     */
@Override
protected Drawable getIconDrawable() {
    final float iconSize = getDimension(R.dimen.fab_icon_size);
    final float iconHalfSize = iconSize / 2f;
    final float plusSize = getDimension(R.dimen.fab_plus_icon_size);
    final float plusHalfStroke = getDimension(R.dimen.fab_plus_icon_stroke) / 2f;
    final float plusOffset = (iconSize - plusSize) / 2f;
    final Shape shape = new Shape() {

        @Override
        public void draw(Canvas canvas, Paint paint) {
            canvas.drawRect(plusOffset, iconHalfSize - plusHalfStroke, iconSize - plusOffset, iconHalfSize + plusHalfStroke, paint);
            canvas.drawRect(iconHalfSize - plusHalfStroke, plusOffset, iconHalfSize + plusHalfStroke, iconSize - plusOffset, paint);
        }
    };
    ShapeDrawable drawable = new ShapeDrawable(shape);
    final Paint paint = drawable.getPaint();
    paint.setColor(mPlusColor);
    paint.setStyle(Style.FILL);
    paint.setAntiAlias(true);
    return drawable;
}
Also used : Shape(android.graphics.drawable.shapes.Shape) Canvas(android.graphics.Canvas) ShapeDrawable(android.graphics.drawable.ShapeDrawable) Paint(android.graphics.Paint)

Example 2 with Shape

use of android.graphics.drawable.shapes.Shape in project KJFrameForAndroid by kymjs.

the class ShapeHolder method setWidth.

public void setWidth(float width) {
    Shape s = shape.getShape();
    s.resize(width, s.getHeight());
}
Also used : Shape(android.graphics.drawable.shapes.Shape)

Example 3 with Shape

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

the class AddFloatingActionButton method getIconDrawable.

@Override
Drawable getIconDrawable() {
    final float iconSize = getDimension(R.dimen.fab_icon_size);
    final float iconHalfSize = iconSize / 2f;
    final float plusSize = getDimension(R.dimen.fab_plus_icon_size);
    final float plusHalfStroke = getDimension(R.dimen.fab_plus_icon_stroke) / 2f;
    final float plusOffset = (iconSize - plusSize) / 2f;
    final Shape shape = new Shape() {

        @Override
        public void draw(Canvas canvas, Paint paint) {
            canvas.drawRect(plusOffset, iconHalfSize - plusHalfStroke, iconSize - plusOffset, iconHalfSize + plusHalfStroke, paint);
            canvas.drawRect(iconHalfSize - plusHalfStroke, plusOffset, iconHalfSize + plusHalfStroke, iconSize - plusOffset, paint);
        }
    };
    ShapeDrawable drawable = new ShapeDrawable(shape);
    final Paint paint = drawable.getPaint();
    paint.setColor(mPlusColor);
    paint.setStyle(Style.FILL);
    paint.setAntiAlias(true);
    return drawable;
}
Also used : Shape(android.graphics.drawable.shapes.Shape) Canvas(android.graphics.Canvas) ShapeDrawable(android.graphics.drawable.ShapeDrawable) Paint(android.graphics.Paint)

Example 4 with Shape

use of android.graphics.drawable.shapes.Shape in project PhotoNoter by yydcdut.

the class AddFloatingActionButton method getIconDrawable.

@Override
Drawable getIconDrawable() {
    final float iconSize = getDimension(R.dimen.fab_icon_size);
    final float iconHalfSize = iconSize / 2f;
    final float plusSize = getDimension(R.dimen.fab_plus_icon_size);
    final float plusHalfStroke = getDimension(R.dimen.fab_plus_icon_stroke) / 2f;
    final float plusOffset = (iconSize - plusSize) / 2f;
    final Shape shape = new Shape() {

        @Override
        public void draw(Canvas canvas, Paint paint) {
            canvas.drawRect(plusOffset, iconHalfSize - plusHalfStroke, iconSize - plusOffset, iconHalfSize + plusHalfStroke, paint);
            canvas.drawRect(iconHalfSize - plusHalfStroke, plusOffset, iconHalfSize + plusHalfStroke, iconSize - plusOffset, paint);
        }
    };
    ShapeDrawable drawable = new ShapeDrawable(shape);
    final Paint paint = drawable.getPaint();
    paint.setColor(mPlusColor);
    paint.setStyle(Style.FILL);
    paint.setAntiAlias(true);
    return drawable;
}
Also used : Shape(android.graphics.drawable.shapes.Shape) Canvas(android.graphics.Canvas) ShapeDrawable(android.graphics.drawable.ShapeDrawable) Paint(android.graphics.Paint)

Example 5 with Shape

use of android.graphics.drawable.shapes.Shape in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class AddFloatingActionButton method getIconDrawable.

@Override
Drawable getIconDrawable() {
    final float iconSize = getDimension(R.dimen.fab_icon_size);
    final float iconHalfSize = iconSize / 2f;
    final float plusSize = getDimension(R.dimen.fab_plus_icon_size);
    final float plusHalfStroke = getDimension(R.dimen.fab_plus_icon_stroke) / 2f;
    final float plusOffset = (iconSize - plusSize) / 2f;
    final Shape shape = new Shape() {

        @Override
        public void draw(Canvas canvas, Paint paint) {
            canvas.drawRect(plusOffset, iconHalfSize - plusHalfStroke, iconSize - plusOffset, iconHalfSize + plusHalfStroke, paint);
            canvas.drawRect(iconHalfSize - plusHalfStroke, plusOffset, iconHalfSize + plusHalfStroke, iconSize - plusOffset, paint);
        }
    };
    ShapeDrawable drawable = new ShapeDrawable(shape);
    final Paint paint = drawable.getPaint();
    paint.setColor(mPlusColor);
    paint.setStyle(Style.FILL);
    paint.setAntiAlias(true);
    return drawable;
}
Also used : Shape(android.graphics.drawable.shapes.Shape) Canvas(android.graphics.Canvas) ShapeDrawable(android.graphics.drawable.ShapeDrawable) Paint(android.graphics.Paint)

Aggregations

Shape (android.graphics.drawable.shapes.Shape)10 ShapeDrawable (android.graphics.drawable.ShapeDrawable)6 Canvas (android.graphics.Canvas)5 Paint (android.graphics.Paint)5 TypedArray (android.content.res.TypedArray)1 OvalShape (android.graphics.drawable.shapes.OvalShape)1 MotionEvent (android.view.MotionEvent)1 View (android.view.View)1 ImageView (android.widget.ImageView)1