Example usage for android.content.res TypedArray getDimension

List of usage examples for android.content.res TypedArray getDimension

Introduction

In this page you can find the example usage for android.content.res TypedArray getDimension.

Prototype

public float getDimension(@StyleableRes int index, float defValue) 

Source Link

Document

Retrieve a dimensional unit attribute at index.

Usage

From source file:com.alibaba.akita.widget.CirclePageIndicator.java

public CirclePageIndicator(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);

    //Load defaults from resources
    final Resources res = getResources();
    final int defaultPageColor = res.getColor(R.color.default_circle_indicator_page_color);
    final int defaultFillColor = res.getColor(R.color.default_circle_indicator_fill_color);
    final int defaultOrientation = res.getInteger(R.integer.default_circle_indicator_orientation);
    final int defaultStrokeColor = res.getColor(R.color.default_circle_indicator_stroke_color);
    final float defaultStrokeWidth = res.getDimension(R.dimen.default_circle_indicator_stroke_width);
    final float defaultRadius = res.getDimension(R.dimen.default_circle_indicator_radius);
    final boolean defaultCentered = res.getBoolean(R.bool.default_circle_indicator_centered);
    final boolean defaultSnap = res.getBoolean(R.bool.default_circle_indicator_snap);

    //Retrieve styles attributes
    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.CirclePageIndicator, defStyle,
            R.style.Widget_CirclePageIndicator);

    mCentered = a.getBoolean(R.styleable.CirclePageIndicator_centered, defaultCentered);
    mOrientation = a.getInt(R.styleable.CirclePageIndicator_orientation, defaultOrientation);
    mPaintPageFill = new Paint(Paint.ANTI_ALIAS_FLAG);
    mPaintPageFill.setStyle(Style.FILL);
    mPaintPageFill.setColor(a.getColor(R.styleable.CirclePageIndicator_pageColor, defaultPageColor));
    mPaintStroke = new Paint(Paint.ANTI_ALIAS_FLAG);
    mPaintStroke.setStyle(Style.STROKE);
    mPaintStroke.setColor(a.getColor(R.styleable.CirclePageIndicator_strokeColor, defaultStrokeColor));
    mPaintStroke//from  ww w  . java  2 s .  co m
            .setStrokeWidth(a.getDimension(R.styleable.CirclePageIndicator_strokeWidth, defaultStrokeWidth));
    mPaintFill = new Paint(Paint.ANTI_ALIAS_FLAG);
    mPaintFill.setStyle(Style.FILL);
    mPaintFill.setColor(a.getColor(R.styleable.CirclePageIndicator_fillColor, defaultFillColor));
    mRadius = a.getDimension(R.styleable.CirclePageIndicator_radius, defaultRadius);
    mSnap = a.getBoolean(R.styleable.CirclePageIndicator_snap, defaultSnap);

    a.recycle();

    final ViewConfiguration configuration = ViewConfiguration.get(context);
    mTouchSlop = ViewConfigurationCompat.getScaledPagingTouchSlop(configuration);
}

From source file:com.progekt.webtools.viewpagerindicator.CirclePageIndicator.java

public CirclePageIndicator(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);

    //Load defaults from resources
    final Resources res = getResources();
    final int defaultPageColor = res.getColor(R.color.default_circle_indicator_page_color);
    final int defaultFillColor = res.getColor(R.color.default_circle_indicator_fill_color);
    final int defaultOrientation = res.getInteger(R.integer.default_circle_indicator_orientation);
    final int defaultStrokeColor = res.getColor(R.color.default_circle_indicator_stroke_color);
    final float defaultStrokeWidth = res.getDimension(R.dimen.default_circle_indicator_stroke_width);
    final float defaultRadius = res.getDimension(R.dimen.default_circle_indicator_radius);
    final boolean defaultCentered = res.getBoolean(R.bool.default_circle_indicator_centered);
    final boolean defaultSnap = res.getBoolean(R.bool.default_circle_indicator_snap);

    //Retrieve styles attributes
    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.CirclePageIndicator, defStyle,
            R.style.Widget_CirclePageIndicator);

    mCentered = a.getBoolean(R.styleable.CirclePageIndicator_centered, defaultCentered);
    mOrientation = a.getInt(R.styleable.CirclePageIndicator_android_orientation, defaultOrientation);
    mPaintPageFill = new Paint(Paint.ANTI_ALIAS_FLAG);
    mPaintPageFill.setStyle(Style.FILL);
    mPaintPageFill.setColor(a.getColor(R.styleable.CirclePageIndicator_pageColor, defaultPageColor));
    mPaintStroke = new Paint(Paint.ANTI_ALIAS_FLAG);
    mPaintStroke.setStyle(Style.STROKE);
    mPaintStroke.setColor(a.getColor(R.styleable.CirclePageIndicator_strokeColor, defaultStrokeColor));
    mPaintStroke/*from   w w  w .ja  v  a2 s  .c  om*/
            .setStrokeWidth(a.getDimension(R.styleable.CirclePageIndicator_strokeWidth, defaultStrokeWidth));
    mPaintFill = new Paint(Paint.ANTI_ALIAS_FLAG);
    mPaintFill.setStyle(Style.FILL);
    mPaintFill.setColor(a.getColor(R.styleable.CirclePageIndicator_fillColor, defaultFillColor));
    mRadius = a.getDimension(R.styleable.CirclePageIndicator_radius, defaultRadius);
    mSnap = a.getBoolean(R.styleable.CirclePageIndicator_snap, defaultSnap);

    a.recycle();

    final ViewConfiguration configuration = ViewConfiguration.get(context);
    mTouchSlop = ViewConfigurationCompat.getScaledPagingTouchSlop(configuration);
}

From source file:com.waz.zclient.views.images.CircularSeekBar.java

/**
 * Initialize the CircularSeekBar with the attributes from the XML style.
 * Uses the defaults defined at the top of this file when an attribute is not specified by the user.
 *
 * @param attrArray TypedArray containing the attributes.
 *//*  w w w .j  a v a  2s .  c o m*/
protected void initAttributes(TypedArray attrArray) {
    circleXRadius = attrArray.getDimension(R.styleable.CircularSeekBar_circle_x_radius,
            DEFAULT_CIRCLE_X_RADIUS * dpToPxScale);
    circleYRadius = attrArray.getDimension(R.styleable.CircularSeekBar_circle_y_radius,
            DEFAULT_CIRCLE_Y_RADIUS * dpToPxScale);
    pointerRadius = attrArray.getDimension(R.styleable.CircularSeekBar_pointer_radius,
            DEFAULT_POINTER_RADIUS * dpToPxScale);
    pointerHaloWidth = attrArray.getDimension(R.styleable.CircularSeekBar_pointer_halo_width,
            DEFAULT_POINTER_HALO_WIDTH * dpToPxScale);
    pointerHaloBorderWidth = attrArray.getDimension(R.styleable.CircularSeekBar_pointer_halo_border_width,
            DEFAULT_POINTER_HALO_BORDER_WIDTH * dpToPxScale);
    circleStrokeWidth = attrArray.getDimension(R.styleable.CircularSeekBar_circle_stroke_width,
            DEFAULT_CIRCLE_STROKE_WIDTH * dpToPxScale);

    String tempColor = attrArray.getString(R.styleable.CircularSeekBar_pointer_color);
    if (tempColor != null) {
        try {
            pointerColor = Color.parseColor(tempColor);
        } catch (IllegalArgumentException e) {
            pointerColor = DEFAULT_POINTER_COLOR;
        }
    }

    tempColor = attrArray.getString(R.styleable.CircularSeekBar_pointer_halo_color);
    if (tempColor != null) {
        try {
            pointerHaloColor = Color.parseColor(tempColor);
        } catch (IllegalArgumentException e) {
            pointerHaloColor = DEFAULT_POINTER_HALO_COLOR;
        }
    }

    tempColor = attrArray.getString(R.styleable.CircularSeekBar_pointer_halo_color_ontouch);
    if (tempColor != null) {
        try {
            pointerHaloColorOnTouch = Color.parseColor(tempColor);
        } catch (IllegalArgumentException e) {
            pointerHaloColorOnTouch = DEFAULT_POINTER_HALO_COLOR_ONTOUCH;
        }
    }

    tempColor = attrArray.getString(R.styleable.CircularSeekBar_circle_color);
    if (tempColor != null) {
        try {
            circleColor = Color.parseColor(tempColor);
        } catch (IllegalArgumentException e) {
            circleColor = DEFAULT_CIRCLE_COLOR;
        }
    }

    tempColor = attrArray.getString(R.styleable.CircularSeekBar_circle_progress_color);
    if (tempColor != null) {
        try {
            circleProgressColor = Color.parseColor(tempColor);
        } catch (IllegalArgumentException e) {
            circleProgressColor = DEFAULT_CIRCLE_PROGRESS_COLOR;
        }
    }

    tempColor = attrArray.getString(R.styleable.CircularSeekBar_circle_fill);
    if (tempColor != null) {
        try {
            circleFillColor = Color.parseColor(tempColor);
        } catch (IllegalArgumentException e) {
            circleFillColor = DEFAULT_CIRCLE_FILL_COLOR;
        }
    }

    pointerAlpha = Color.alpha(pointerHaloColor);

    pointerAlphaOnTouch = attrArray.getInt(R.styleable.CircularSeekBar_pointer_alpha_ontouch,
            DEFAULT_POINTER_ALPHA_ONTOUCH);
    if (pointerAlphaOnTouch > 255 || pointerAlphaOnTouch < 0) {
        pointerAlphaOnTouch = DEFAULT_POINTER_ALPHA_ONTOUCH;
    }

    max = attrArray.getInt(R.styleable.CircularSeekBar_max, DEFAULT_MAX);
    progress = attrArray.getInt(R.styleable.CircularSeekBar_progress, DEFAULT_PROGRESS);
    customRadii = attrArray.getBoolean(R.styleable.CircularSeekBar_use_custom_radii, DEFAULT_USE_CUSTOM_RADII);
    maintainEqualCircle = attrArray.getBoolean(R.styleable.CircularSeekBar_maintain_equal_circle,
            DEFAULT_MAINTAIN_EQUAL_CIRCLE);
    moveOutsideCircle = attrArray.getBoolean(R.styleable.CircularSeekBar_move_outside_circle,
            DEFAULT_MOVE_OUTSIDE_CIRCLE);

    // Modulo 360 right now to avoid constant conversion
    startAngle = ((360f
            + (attrArray.getFloat((R.styleable.CircularSeekBar_start_angle), DEFAULT_START_ANGLE) % 360f))
            % 360f);
    endAngle = ((360f + (attrArray.getFloat((R.styleable.CircularSeekBar_end_angle), DEFAULT_END_ANGLE) % 360f))
            % 360f);

    if (MathUtils.floatEqual(startAngle, endAngle)) {
        //startAngle = startAngle + 1f;
        endAngle = endAngle - .1f;
    }
    final GestureDetector.SimpleOnGestureListener gestureListener = new GestureDetector.SimpleOnGestureListener() {
        @Override
        public boolean onSingleTapConfirmed(MotionEvent e) {
            if (onArtClickListener != null) {
                onArtClickListener.onSingleClick();
                return true;
            }
            return false;
        }

        @Override
        public boolean onDoubleTap(MotionEvent e) {
            if (onArtClickListener != null) {
                onArtClickListener.onDoubleClick();
            }
            return super.onDoubleTap(e);
        }

        @Override
        public void onLongPress(MotionEvent e) {
            performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
            if (onArtLongClickListener != null) {
                onArtLongClickListener.onLongClick(CircularSeekBar.this);
            }
        }
    };
    gestureDetector = new GestureDetectorCompat(getContext(), gestureListener);
    gestureDetector.setOnDoubleTapListener(gestureListener);
}

From source file:com.klinker.deskclock.widget.multiwaveview.GlowPadView.java

public GlowPadView(Context context, AttributeSet attrs) {
    super(context, attrs);
    Resources res = context.getResources();

    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.GlowPadView);
    mInnerRadius = a.getDimension(R.styleable.GlowPadView_innerRadius, mInnerRadius);
    mOuterRadius = a.getDimension(R.styleable.GlowPadView_outerRadius, mOuterRadius);
    mSnapMargin = a.getDimension(R.styleable.GlowPadView_snapMargin, mSnapMargin);
    mVibrationDuration = a.getInt(R.styleable.GlowPadView_vibrationDuration, mVibrationDuration);
    mFeedbackCount = a.getInt(R.styleable.GlowPadView_feedbackCount, mFeedbackCount);
    TypedValue handle = a.peekValue(R.styleable.GlowPadView_handleDrawable);
    mHandleDrawable = new TargetDrawable(res, handle != null ? handle.resourceId : 0, 2);
    mHandleDrawable.setState(TargetDrawable.STATE_INACTIVE);
    mOuterRing = new TargetDrawable(res, getResourceId(a, R.styleable.GlowPadView_outerRingDrawable), 1);

    mAlwaysTrackFinger = a.getBoolean(R.styleable.GlowPadView_alwaysTrackFinger, false);

    int pointId = getResourceId(a, R.styleable.GlowPadView_pointDrawable);
    Drawable pointDrawable = pointId != 0 ? res.getDrawable(pointId) : null;
    mGlowRadius = a.getDimension(R.styleable.GlowPadView_glowRadius, 0.0f);

    TypedValue outValue = new TypedValue();

    // Read array of target drawables
    if (a.getValue(R.styleable.GlowPadView_targetDrawables, outValue)) {
        internalSetTargetResources(outValue.resourceId);
    }//from www  .j  a v  a2 s .  c o m
    if (mTargetDrawables == null || mTargetDrawables.size() == 0) {
        throw new IllegalStateException("Must specify at least one target drawable");
    }

    // Read array of target descriptions
    if (a.getValue(R.styleable.GlowPadView_targetDescriptions, outValue)) {
        final int resourceId = outValue.resourceId;
        if (resourceId == 0) {
            throw new IllegalStateException("Must specify target descriptions");
        }
        setTargetDescriptionsResourceId(resourceId);
    }

    // Read array of direction descriptions
    if (a.getValue(R.styleable.GlowPadView_directionDescriptions, outValue)) {
        final int resourceId = outValue.resourceId;
        if (resourceId == 0) {
            throw new IllegalStateException("Must specify direction descriptions");
        }
        setDirectionDescriptionsResourceId(resourceId);
    }

    a.recycle();

    // Use gravity attribute from LinearLayout
    //a = context.obtainStyledAttributes(attrs, R.styleable.LinearLayout);
    mGravity = a.getInt(R.styleable.GlowPadView_android_gravity, Gravity.TOP);
    a.recycle();

    setVibrateEnabled(mVibrationDuration > 0);

    assignDefaultsIfNeeded();

    mPointCloud = new PointCloud(pointDrawable);
    mPointCloud.makePointCloud(mInnerRadius, mOuterRadius);
    mPointCloud.glowManager.setRadius(mGlowRadius);
}

From source file:com.tangjie.androiddemocollection.widget.viewpageindicator.CirclePageIndicator.java

public CirclePageIndicator(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);

    //Load defaults from resources
    final Resources res = getResources();
    final int defaultPageColor = res.getColor(R.color.default_circle_indicator_page_color);
    final int defaultFillColor = res.getColor(R.color.default_circle_indicator_fill_color);
    final int defaultOrientation = res.getInteger(R.integer.default_circle_indicator_orientation);
    final int defaultStrokeColor = res.getColor(R.color.default_circle_indicator_stroke_color);
    final float defaultStrokeWidth = res.getDimension(R.dimen.default_circle_indicator_stroke_width);
    final float defaultRadius = res.getDimension(R.dimen.default_circle_indicator_radius);
    final boolean defaultCentered = res.getBoolean(R.bool.default_circle_indicator_centered);
    final boolean defaultSnap = res.getBoolean(R.bool.default_circle_indicator_snap);

    //Retrieve styles attributes
    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.CirclePageIndicator, defStyle,
            R.style.Widget_CirclePageIndicator);

    mCentered = a.getBoolean(R.styleable.CirclePageIndicator_centeredd, defaultCentered);
    mOrientation = a.getInt(R.styleable.CirclePageIndicator_orientation, defaultOrientation);
    mPaintPageFill = new Paint(Paint.ANTI_ALIAS_FLAG);
    mPaintPageFill.setStyle(Style.FILL);
    mPaintPageFill.setColor(a.getColor(R.styleable.CirclePageIndicator_pageColor, defaultPageColor));
    mPaintStroke = new Paint(Paint.ANTI_ALIAS_FLAG);
    mPaintStroke.setStyle(Style.STROKE);
    mPaintStroke.setColor(a.getColor(R.styleable.CirclePageIndicator_strokeColorr, defaultStrokeColor));
    mPaintStroke//from w w w .j a va2  s.  c o  m
            .setStrokeWidth(a.getDimension(R.styleable.CirclePageIndicator_strokeWidth, defaultStrokeWidth));
    mPaintFill = new Paint(Paint.ANTI_ALIAS_FLAG);
    mPaintFill.setStyle(Style.FILL);
    mPaintFill.setColor(a.getColor(R.styleable.CirclePageIndicator_fillColorr, defaultFillColor));
    mRadius = a.getDimension(R.styleable.CirclePageIndicator_radiuss, defaultRadius);
    mSnap = a.getBoolean(R.styleable.CirclePageIndicator_snap, defaultSnap);

    a.recycle();

    final ViewConfiguration configuration = ViewConfiguration.get(context);
    mTouchSlop = ViewConfigurationCompat.getScaledPagingTouchSlop(configuration);
}

From source file:com.marshalchen.ultimaterecyclerview.UltimateRecyclerView.java

protected void initAttrs(AttributeSet attrs) {
    TypedArray typedArray = getContext().obtainStyledAttributes(attrs, R.styleable.UltimateRecyclerview);

    try {// ww w .  ja  v  a 2 s.c o  m
        mPadding = (int) typedArray.getDimension(R.styleable.UltimateRecyclerview_recyclerviewPadding, -1.1f);
        mPaddingTop = (int) typedArray.getDimension(R.styleable.UltimateRecyclerview_recyclerviewPaddingTop,
                0.0f);
        mPaddingBottom = (int) typedArray
                .getDimension(R.styleable.UltimateRecyclerview_recyclerviewPaddingBottom, 0.0f);
        mPaddingLeft = (int) typedArray.getDimension(R.styleable.UltimateRecyclerview_recyclerviewPaddingLeft,
                0.0f);
        mPaddingRight = (int) typedArray.getDimension(R.styleable.UltimateRecyclerview_recyclerviewPaddingRight,
                0.0f);
        mClipToPadding = typedArray.getBoolean(R.styleable.UltimateRecyclerview_recyclerviewClipToPadding,
                false);
        mEmptyId = typedArray.getResourceId(R.styleable.UltimateRecyclerview_recyclerviewEmptyView, 0);
        mFloatingButtonId = typedArray
                .getResourceId(R.styleable.UltimateRecyclerview_recyclerviewFloatingActionView, 0);
        mScrollbarsStyle = typedArray.getInt(R.styleable.UltimateRecyclerview_recyclerviewScrollbars,
                SCROLLBARS_NONE);
        int colorList = typedArray.getResourceId(R.styleable.UltimateRecyclerview_recyclerviewDefaultSwipeColor,
                0);
        if (colorList != 0) {
            defaultSwipeToDismissColors = getResources().getIntArray(colorList);
        }
    } finally {
        typedArray.recycle();
    }
}

From source file:org.taptwo.android.widget.CircleIndicator.java

public CircleIndicator(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    if (isInEditMode())
        return;/*from w w w . j  a va2  s.  c om*/
    // Retrieve styles attributs
    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.CircleIndicator);

    // Gets the inactive circle type, defaulting to "fill"
    int activeType = a.getInt(R.styleable.CircleIndicator_activeType, STYLE_FILL);

    int activeDefaultColor = 0xFFFFFFFF;

    // Get a custom inactive color if there is one
    int activeColor = a.getColor(R.styleable.CircleIndicator_activeColor, activeDefaultColor);

    // Gets the inactive circle type, defaulting to "stroke"
    int inactiveType = a.getInt(R.styleable.CircleIndicator_inactiveType, STYLE_STROKE);

    int inactiveDefaultColor = 0x44FFFFFF;
    // Get a custom inactive color if there is one
    int inactiveColor = a.getColor(R.styleable.CircleIndicator_inactiveColor, inactiveDefaultColor);

    // Retrieve the radius
    mRadius = a.getDimension(R.styleable.CircleIndicator_radius, 4.0f);
    mActiveRadius = a.getDimension(R.styleable.CircleIndicator_activeRadius, 0.5f);
    mCentered = a.getBoolean(R.styleable.CircleIndicator_centered, true);

    mOrientation = a.getInt(R.styleable.CircleIndicator_android_orientation, HORIZONTAL);
    mSnap = a.getBoolean(R.styleable.CircleIndicator_snap, false);

    mStroke = a.getBoolean(R.styleable.CircleIndicator_stroke, false);

    mPaintStroke.setStyle(Style.STROKE);
    mPaintStroke.setColor(a.getColor(R.styleable.CircleIndicator_strokeColor, Color.parseColor("#FFDDDDDD")));
    mPaintStroke.setStrokeWidth(a.getDimension(R.styleable.CircleIndicator_strokeWidth, 2.5f));

    a.recycle();

    final ViewConfiguration configuration = ViewConfiguration.get(context);
    mTouchSlop = ViewConfigurationCompat.getScaledPagingTouchSlop(configuration);
    initColors(activeColor, inactiveColor, activeType, inactiveType);
}

From source file:com.triggertrap.seekarc.SeekArc.java

private void init(Context context, AttributeSet attrs, int defStyle) {
    Log.d(TAG, "Initialising SeekArc");
    float density = context.getResources().getDisplayMetrics().density;

    // Defaults, may need to link this into theme settings
    int arcColor = ContextCompat.getColor(context, R.color.progress_gray);
    int progressColor = ContextCompat.getColor(context, R.color.default_blue_light);
    // Convert progress width to pixels for current density
    mProgressWidth = (int) (mProgressWidth * density);

    if (attrs != null) {
        // Attribute initialization
        final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.SeekArc, defStyle, 0);

        arcColor = a.getColor(R.styleable.SeekArc_arcColor, arcColor);
        progressColor = a.getColor(R.styleable.SeekArc_progressColor, progressColor);

        Drawable thumb = a.getDrawable(R.styleable.SeekArc_thumb);
        if (thumb != null) {
            setThumb(thumb);/*www.  j a v  a2 s.c  o m*/
            mThumb.setColorFilter(progressColor, PorterDuff.Mode.SRC_IN);
        } else {
            setThumb(ContextCompat.getDrawable(context, R.drawable.seek_arc_control_selector));
        }

        mMax = a.getInteger(R.styleable.SeekArc_max, mMax);
        mProgress = a.getInteger(R.styleable.SeekArc_progress, mProgress);
        mProgressWidth = (int) a.getDimension(R.styleable.SeekArc_progressWidth, mProgressWidth);
        mArcWidth = (int) a.getDimension(R.styleable.SeekArc_arcWidth, mArcWidth);
        mStartAngle = a.getInt(R.styleable.SeekArc_startAngle, mStartAngle);
        mSweepAngle = a.getInt(R.styleable.SeekArc_sweepAngle, mSweepAngle);
        mRotation = a.getInt(R.styleable.SeekArc_rotation, mRotation);
        mRoundedEdges = a.getBoolean(R.styleable.SeekArc_roundEdges, mRoundedEdges);
        mTouchInside = a.getBoolean(R.styleable.SeekArc_touchInside, mTouchInside);
        mClockwise = a.getBoolean(R.styleable.SeekArc_clockwise, mClockwise);
        mEnabled = a.getBoolean(R.styleable.SeekArc_enabled, mEnabled);

        a.recycle();
    }

    mProgress = (mProgress > mMax) ? mMax : mProgress;
    mProgress = (mProgress < 0) ? 0 : mProgress;

    mSweepAngle = (mSweepAngle > 360) ? 360 : mSweepAngle;
    mSweepAngle = (mSweepAngle < 0) ? 0 : mSweepAngle;

    mProgressSweep = (float) mProgress / mMax * mSweepAngle;

    mStartAngle = (mStartAngle > 360) ? 0 : mStartAngle;
    mStartAngle = (mStartAngle < 0) ? 0 : mStartAngle;

    mArcPaint = new Paint();
    mArcPaint.setColor(arcColor);
    mArcPaint.setAntiAlias(true);
    mArcPaint.setStyle(Paint.Style.STROKE);
    mArcPaint.setStrokeWidth(mArcWidth);
    //mArcPaint.setAlpha(45);

    mProgressPaint = new Paint();
    mProgressPaint.setColor(progressColor);
    mProgressPaint.setAntiAlias(true);
    mProgressPaint.setStyle(Paint.Style.STROKE);
    mProgressPaint.setStrokeWidth(mProgressWidth);

    if (mRoundedEdges) {
        mArcPaint.setStrokeCap(Paint.Cap.ROUND);
        mProgressPaint.setStrokeCap(Paint.Cap.ROUND);
    }
}

From source file:com.ipmph.v.viewpagerindicator.CirclePageIndicator.java

public CirclePageIndicator(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    if (isInEditMode())
        return;//from   w  w w.  j a  v a  2s. c  om
    LayoutParams params = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.WRAP_CONTENT);
    setLayoutParams(params);
    //Load defaults from resources
    final Resources res = getResources();
    final int defaultPageColor = res.getColor(R.color.default_circle_indicator_page_color);
    final int defaultFillColor = res.getColor(R.color.default_circle_indicator_fill_color);
    final int defaultOrientation = res.getInteger(R.integer.default_circle_indicator_orientation);
    final int defaultStrokeColor = res.getColor(R.color.default_circle_indicator_stroke_color);
    final float defaultStrokeWidth = res.getDimension(R.dimen.default_circle_indicator_stroke_width);
    final float defaultRadius = res.getDimension(R.dimen.default_circle_indicator_radius);
    final boolean defaultCentered = res.getBoolean(R.bool.default_circle_indicator_centered);
    final boolean defaultSnap = res.getBoolean(R.bool.default_circle_indicator_snap);

    //Retrieve styles attributes
    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.CirclePageIndicator, defStyle, 0);

    mCentered = a.getBoolean(R.styleable.CirclePageIndicator_centered, defaultCentered);
    mOrientation = a.getInt(R.styleable.CirclePageIndicator_android_orientation, defaultOrientation);
    mPaintPageFill.setStyle(Style.FILL);
    mPaintPageFill.setColor(a.getColor(R.styleable.CirclePageIndicator_pageColor, defaultPageColor));
    mPaintStroke.setStyle(Style.STROKE);
    mPaintStroke.setColor(a.getColor(R.styleable.CirclePageIndicator_strokeColor, defaultStrokeColor));
    mPaintStroke.setStrokeWidth(defaultStrokeWidth);
    mPaintFill.setStyle(Style.FILL);
    mPaintFill.setColor(a.getColor(R.styleable.CirclePageIndicator_fillColor, defaultFillColor));
    mRadius = a.getDimension(R.styleable.CirclePageIndicator_radius, defaultRadius);
    mSnap = a.getBoolean(R.styleable.CirclePageIndicator_snap, defaultSnap);

    Drawable background = a.getDrawable(R.styleable.CirclePageIndicator_android_background);
    if (background != null) {
        setBackgroundDrawable(background);
    }

    a.recycle();

    final ViewConfiguration configuration = ViewConfiguration.get(context);
    mTouchSlop = ViewConfigurationCompat.getScaledPagingTouchSlop(configuration);
}

From source file:com.base.view.slidemenu.SlideMenu.java

public SlideMenu(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    // we want to draw drop shadow of content
    mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop();
    mVelocityTracker = VelocityTracker.obtain();
    mContentHitRect = new Rect();
    mEdgeSlideDetectRect = new Rect();
    STATUS_BAR_HEIGHT = (int) getStatusBarHeight(context);
    setWillNotDraw(false);//from ww w.j a v  a2s .  co  m

    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.SlideMenu, defStyle, 0);

    // Set the shadow attributes
    setPrimaryShadowWidth(a.getDimension(R.styleable.SlideMenu_primaryShadowWidth, 30));
    setSecondaryShadowWidth(a.getDimension(R.styleable.SlideMenu_secondaryShadowWidth, 30));

    Drawable primaryShadowDrawable = a.getDrawable(R.styleable.SlideMenu_primaryShadowDrawable);
    if (null == primaryShadowDrawable) {
        primaryShadowDrawable = new GradientDrawable(Orientation.LEFT_RIGHT,
                new int[] { Color.TRANSPARENT, Color.argb(99, 0, 0, 0) });
    }
    setPrimaryShadowDrawable(primaryShadowDrawable);

    Drawable secondaryShadowDrawable = a.getDrawable(R.styleable.SlideMenu_secondaryShadowDrawable);
    if (null == secondaryShadowDrawable) {
        secondaryShadowDrawable = new GradientDrawable(Orientation.LEFT_RIGHT,
                new int[] { Color.argb(99, 0, 0, 0), Color.TRANSPARENT });
    }
    setSecondaryShadowDrawable(secondaryShadowDrawable);

    int interpolatorResId = a.getResourceId(R.styleable.SlideMenu_interpolator, -1);
    setInterpolator(-1 == interpolatorResId ? DEFAULT_INTERPOLATOR
            : AnimationUtils.loadInterpolator(context, interpolatorResId));

    mSlideDirectionFlag = a.getInt(R.styleable.SlideMenu_slideDirection,
            FLAG_DIRECTION_LEFT | FLAG_DIRECTION_RIGHT);

    setEdgeSlideEnable(a.getBoolean(R.styleable.SlideMenu_edgeSlide, false));
    setEdgetSlideWidth(a.getDimensionPixelSize(R.styleable.SlideMenu_edgeSlideWidth, 100));
    a.recycle();

    setFocusable(true);
    setFocusableInTouchMode(true);
}