Search in sources :

Example 6 with Shape

use of android.graphics.drawable.shapes.Shape in project NineOldAndroids by JakeWharton.

the class ShapeHolder method setHeight.

public void setHeight(float height) {
    Shape s = shape.getShape();
    s.resize(s.getWidth(), height);
}
Also used : Shape(android.graphics.drawable.shapes.Shape)

Example 7 with Shape

use of android.graphics.drawable.shapes.Shape in project NineOldAndroids by JakeWharton.

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 8 with Shape

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

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 9 with Shape

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

the class ShapeHolder method setHeight.

public void setHeight(float height) {
    Shape s = shape.getShape();
    s.resize(s.getWidth(), height);
}
Also used : Shape(android.graphics.drawable.shapes.Shape)

Example 10 with Shape

use of android.graphics.drawable.shapes.Shape in project uk.co.jasonfry.android.tools by jsonfry.

the class PageControl method initPageControl.

private void initPageControl() {
    Log.i("uk.co.jasonfry.android.tools.ui.PageControl", "Initialising PageControl");
    indicators = new ArrayList<ImageView>();
    activeDrawable = new ShapeDrawable();
    inactiveDrawable = new ShapeDrawable();
    activeDrawable.setBounds(0, 0, mIndicatorSize, mIndicatorSize);
    inactiveDrawable.setBounds(0, 0, mIndicatorSize, mIndicatorSize);
    Shape s1 = new OvalShape();
    s1.resize(mIndicatorSize, mIndicatorSize);
    Shape s2 = new OvalShape();
    s2.resize(mIndicatorSize, mIndicatorSize);
    int[] i = new int[2];
    i[0] = android.R.attr.textColorSecondary;
    i[1] = android.R.attr.textColorSecondaryInverse;
    TypedArray a = mContext.getTheme().obtainStyledAttributes(i);
    ((ShapeDrawable) activeDrawable).getPaint().setColor(a.getColor(0, Color.DKGRAY));
    ((ShapeDrawable) inactiveDrawable).getPaint().setColor(a.getColor(1, Color.LTGRAY));
    ((ShapeDrawable) activeDrawable).setShape(s1);
    ((ShapeDrawable) inactiveDrawable).setShape(s2);
    mIndicatorSize = (int) (mIndicatorSize * getResources().getDisplayMetrics().density);
    setOnTouchListener(new OnTouchListener() {

        public boolean onTouch(View v, MotionEvent event) {
            if (mOnPageControlClickListener != null) {
                switch(event.getAction()) {
                    case MotionEvent.ACTION_UP:
                        if (PageControl.this.getOrientation() == LinearLayout.HORIZONTAL) {
                            if (//if on left of view
                            event.getX() < (PageControl.this.getWidth() / 2)) {
                                if (mCurrentPage > 0) {
                                    mOnPageControlClickListener.goBackwards();
                                }
                            } else //if on right of view
                            {
                                if (mCurrentPage < (mPageCount - 1)) {
                                    mOnPageControlClickListener.goForwards();
                                }
                            }
                        } else {
                            if (//if on top half of view
                            event.getY() < (PageControl.this.getHeight() / 2)) {
                                if (mCurrentPage > 0) {
                                    mOnPageControlClickListener.goBackwards();
                                }
                            } else //if on bottom half of view
                            {
                                if (mCurrentPage < (mPageCount - 1)) {
                                    mOnPageControlClickListener.goForwards();
                                }
                            }
                        }
                        return false;
                }
            }
            return true;
        }
    });
}
Also used : OvalShape(android.graphics.drawable.shapes.OvalShape) Shape(android.graphics.drawable.shapes.Shape) TypedArray(android.content.res.TypedArray) ShapeDrawable(android.graphics.drawable.ShapeDrawable) ImageView(android.widget.ImageView) OvalShape(android.graphics.drawable.shapes.OvalShape) ImageView(android.widget.ImageView) View(android.view.View) MotionEvent(android.view.MotionEvent)

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