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.ickphum.android.isoview.InteractiveLineGraphView.java

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

    TypedArray a = context.getTheme().obtainStyledAttributes(attrs, R.styleable.InteractiveLineGraphView,
            defStyle, defStyle);/* ww  w .  jav  a 2s. c o m*/

    try {
        mLabelTextColor = a.getColor(R.styleable.InteractiveLineGraphView_labelTextColor, mLabelTextColor);
        mLabelTextSize = a.getDimension(R.styleable.InteractiveLineGraphView_labelTextSize, mLabelTextSize);
        mLabelSeparation = a.getDimensionPixelSize(R.styleable.InteractiveLineGraphView_labelSeparation,
                mLabelSeparation);

        mGridThickness = a.getDimension(R.styleable.InteractiveLineGraphView_gridThickness, mGridThickness);
        mGridColor = a.getColor(R.styleable.InteractiveLineGraphView_gridColor, mGridColor);

        mAxisThickness = a.getDimension(R.styleable.InteractiveLineGraphView_axisThickness, mAxisThickness);
        mAxisColor = a.getColor(R.styleable.InteractiveLineGraphView_axisColor, mAxisColor);

        mDataThickness = a.getDimension(R.styleable.InteractiveLineGraphView_dataThickness, mDataThickness);
        mDataColor = a.getColor(R.styleable.InteractiveLineGraphView_dataColor, mDataColor);
    } finally {
        a.recycle();
    }

    initPaints();

    // Sets up interactions
    if (!this.isInEditMode()) {
        mScaleGestureDetector = new ScaleGestureDetector(context, mScaleGestureListener);
        mGestureDetector = new GestureDetectorCompat(context, mGestureListener);
    }

    mScroller = new OverScroller(context);
    mZoomer = new Zoomer(context);

    // Sets up edge effects
    mEdgeEffectLeft = new EdgeEffectCompat(context);
    mEdgeEffectTop = new EdgeEffectCompat(context);
    mEdgeEffectRight = new EdgeEffectCompat(context);
    mEdgeEffectBottom = new EdgeEffectCompat(context);
}

From source file:cn.androidy.androiddevelopmentpatterns.interactivechart.InteractiveLineGraphView.java

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

    TypedArray a = context.getTheme().obtainStyledAttributes(attrs, R.styleable.InteractiveLineGraphView,
            defStyle, defStyle);/*  w w  w . j av  a 2s.c  o m*/

    try {
        mLabelTextColor = a.getColor(R.styleable.InteractiveLineGraphView_labelTextColor, mLabelTextColor);
        mLabelTextSize = a.getDimension(R.styleable.InteractiveLineGraphView_labelTextSize, mLabelTextSize);
        mLabelSeparation = a.getDimensionPixelSize(R.styleable.InteractiveLineGraphView_labelSeparation,
                mLabelSeparation);

        mGridThickness = a.getDimension(R.styleable.InteractiveLineGraphView_gridThickness, mGridThickness);
        mGridColor = a.getColor(R.styleable.InteractiveLineGraphView_gridColor, mGridColor);

        mAxisThickness = a.getDimension(R.styleable.InteractiveLineGraphView_axisThickness, mAxisThickness);
        mAxisColor = a.getColor(R.styleable.InteractiveLineGraphView_axisColor, mAxisColor);

        mDataThickness = a.getDimension(R.styleable.InteractiveLineGraphView_dataThickness, mDataThickness);
        mDataColor = a.getColor(R.styleable.InteractiveLineGraphView_dataColor, mDataColor);
    } finally {
        a.recycle();
    }

    initPaints();

    // Sets up interactions
    mScaleGestureDetector = new ScaleGestureDetector(context, mScaleGestureListener);
    mGestureDetector = new GestureDetectorCompat(context, mGestureListener);

    mScroller = new OverScroller(context);
    mZoomer = new Zoomer(context);

    // Sets up edge effects
    mEdgeEffectLeft = new EdgeEffectCompat(context);
    mEdgeEffectTop = new EdgeEffectCompat(context);
    mEdgeEffectRight = new EdgeEffectCompat(context);
    mEdgeEffectBottom = new EdgeEffectCompat(context);
}

From source file:com.jenshen.tovisit.ui.behavior.BottomSheetBehaviorGoogleMapsLike.java

/**
 * Default constructor for inflating BottomSheetBehaviors from layout.
 *
 * @param context The {@link Context}./*from  w  w  w  . j a v  a2 s  .  co  m*/
 * @param attrs   The {@link AttributeSet}.
 */
public BottomSheetBehaviorGoogleMapsLike(Context context, AttributeSet attrs) {
    super(context, attrs);
    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.GoogleMapsSheetBehavior_Params);
    setPeekHeight(a.getDimensionPixelSize(
            R.styleable.GoogleMapsSheetBehavior_Params_googleMaps_behavior_peekHeight, 0));
    setHideable(a.getBoolean(R.styleable.GoogleMapsSheetBehavior_Params_googleMaps_behavior_hideable, false));
    a.recycle();

    /**
     * Getting the anchorPoint...
     */
    mAnchorPoint = DEFAULT_ANCHOR_POINT;
    a = context.obtainStyledAttributes(attrs, R.styleable.CustomBottomSheetBehavior);
    if (attrs != null)
        mAnchorPoint = (int) a.getDimension(R.styleable.CustomBottomSheetBehavior_anchorPoint, 0);
    a.recycle();

    ViewConfiguration configuration = ViewConfiguration.get(context);
    mMaximumVelocity = configuration.getScaledMaximumFlingVelocity();
}

From source file:org.goodev.helpviewpager.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_myorientation, 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 a  2  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.maedi.user.godok.v1.viewpagerindicator.CirclePageIndicator.java

@SuppressWarnings("deprecation")
public CirclePageIndicator(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    if (isInEditMode())
        return;//w w  w.j av a 2  s .c  o m

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

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

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

    Drawable background = a
            .getDrawable(com.viewpagerindicator.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:MyUltimateRecyclerView.MyUltimateRecyclerView.java

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

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

From source file:com.qifeng.theunderseaworld.view.CirclePageIndicator.java

public CirclePageIndicator(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    if (isInEditMode())
        return;/*from  w  w w.j ava 2s. c  om*/

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

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

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

    Drawable background = a
            .getDrawable(com.viewpagerindicator.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:no.srib.app.client.view.CircleIshPageIndicator.java

public CircleIshPageIndicator(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    if (isInEditMode())
        return;/*from   www  .j  ava 2  s . c  om*/

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

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

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

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

    a.recycle();

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

    circle = BitmapFactory.decodeResource(res, R.drawable.ic_viewpager);
    selected = BitmapFactory.decodeResource(res, R.drawable.ic_viewpager_selected);
}

From source file:silent.kuasapmaterial.libs.ProgressWheel.java

/**
 * Parse the attributes passed to the view from the XML
 *
 * @param a the attributes to parse/*from   www  .j av a2s  .c om*/
 */
private void parseAttributes(TypedArray a) {
    // We transform the default values from DIP to pixels
    DisplayMetrics metrics = getContext().getResources().getDisplayMetrics();
    barWidth = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, barWidth, metrics);
    rimWidth = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, rimWidth, metrics);
    circleRadius = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, circleRadius, metrics);

    circleRadius = (int) a.getDimension(R.styleable.ProgressWheel_matProg_circleRadius, circleRadius);

    fillRadius = a.getBoolean(R.styleable.ProgressWheel_matProg_fillRadius, false);

    barWidth = (int) a.getDimension(R.styleable.ProgressWheel_matProg_barWidth, barWidth);

    rimWidth = (int) a.getDimension(R.styleable.ProgressWheel_matProg_rimWidth, rimWidth);

    float baseSpinSpeed = a.getFloat(R.styleable.ProgressWheel_matProg_spinSpeed, spinSpeed / 360.0f);
    spinSpeed = baseSpinSpeed * 360;

    barSpinCycleTime = a.getInt(R.styleable.ProgressWheel_matProg_barSpinCycleTime, (int) barSpinCycleTime);

    barColor = a.getColor(R.styleable.ProgressWheel_matProg_barColor, barColor);

    rimColor = a.getColor(R.styleable.ProgressWheel_matProg_rimColor, rimColor);

    circleColor = a.getColor(R.styleable.ProgressWheel_matProg_circleBackgroundColor, circleColor);
    isCircleBackground = a.getBoolean(R.styleable.ProgressWheel_matProg_circleBackground, isCircleBackground);

    isMaterial = a.getBoolean(R.styleable.ProgressWheel_matProg_material, isMaterial);

    shadowColor = a.getColor(R.styleable.ProgressWheel_matProg_shadowColor, shadowColor);
    isShadow = a.getBoolean(R.styleable.ProgressWheel_matProg_shadow, isShadow);
    mShadowSize = a.getFloat(R.styleable.ProgressWheel_matProg_shadowSize, mShadowSize);

    linearProgress = a.getBoolean(R.styleable.ProgressWheel_matProg_linearProgress, false);

    if (a.getBoolean(R.styleable.ProgressWheel_matProg_progressIndeterminate, false)) {
        spin();
    }

    // Recycle
    a.recycle();
}

From source file:com.seek.ruler.SimpleRulerView.java

/**
 * set default/*w w w  .  j  av  a2  s . c om*/
 * 
 * @param attrs
 */
private void init(AttributeSet attrs) {
    DisplayMetrics dm = getResources().getDisplayMetrics();
    mIntervalDis = dm.density * 5;

    mRulerLineWidth = dm.density * 2;
    mTextSize = dm.scaledDensity * 14;

    TypedArray typedArray = attrs == null ? null
            : getContext().obtainStyledAttributes(attrs, R.styleable.simpleRulerView);
    if (typedArray != null) {
        mHighlightColor = typedArray.getColor(R.styleable.simpleRulerView_highlightColor, mHighlightColor);
        mTextColor = typedArray.getColor(R.styleable.simpleRulerView_textColor, mTextColor);
        mRulerColor = typedArray.getColor(R.styleable.simpleRulerView_rulerColor, mRulerColor);
        mIntervalValue = typedArray.getFloat(R.styleable.simpleRulerView_intervalValue, mIntervalValue);
        mMaxValue = typedArray.getFloat(R.styleable.simpleRulerView_maxValue, mMaxValue);
        mMinValue = typedArray.getFloat(R.styleable.simpleRulerView_minValue, mMinValue);
        mTextSize = typedArray.getDimension(R.styleable.simpleRulerView_textSize, mTextSize);
        mRulerLineWidth = typedArray.getDimension(R.styleable.simpleRulerView_rulerLineWidth, mRulerLineWidth);
        mIntervalDis = typedArray.getDimension(R.styleable.simpleRulerView_intervalDistance, mIntervalDis);
        retainLength = typedArray.getInteger(R.styleable.simpleRulerView_retainLength, 0);
    }

    calculateTotal();

    mRulerPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mRulerPaint.setStrokeWidth(mRulerLineWidth);

    mTextPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG);
    mTextPaint.setTextAlign(Paint.Align.CENTER);
    mTextPaint.setTextSize(mTextSize);

    mGestureDetectorCompat = new GestureDetectorCompat(getContext(), this);
    mScroller = new OverScroller(getContext(), new DecelerateInterpolator());

    setSelectedIndex(0);
}