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:cn.oddcloud.www.navigationtabbar.ntb.NavigationTabBar.java

@SuppressWarnings("ResourceAsColor")
public NavigationTabBar(final Context context, final AttributeSet attrs, final int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    //Init NTB// www . jav a  2s.co  m

    // Always draw
    setWillNotDraw(false);
    // Speed and fix for pre 17 API
    ViewCompat.setLayerType(this, ViewCompat.LAYER_TYPE_SOFTWARE, null);
    setLayerType(LAYER_TYPE_SOFTWARE, null);

    final TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.NavigationTabBar);
    try {
        setIsTitled(typedArray.getBoolean(R.styleable.NavigationTabBar_ntb_titled, false));
        setIsBadged(typedArray.getBoolean(R.styleable.NavigationTabBar_ntb_badged, false));
        setIsScaled(typedArray.getBoolean(R.styleable.NavigationTabBar_ntb_scaled, true));
        setIsTinted(typedArray.getBoolean(R.styleable.NavigationTabBar_ntb_tinted, true));
        setIsSwiped(typedArray.getBoolean(R.styleable.NavigationTabBar_ntb_swiped, true));
        setTitleSize(typedArray.getDimension(R.styleable.NavigationTabBar_ntb_title_size, AUTO_SIZE));
        setIsBadgeUseTypeface(
                typedArray.getBoolean(R.styleable.NavigationTabBar_ntb_badge_use_typeface, false));

        setTitleMode(typedArray.getInt(R.styleable.NavigationTabBar_ntb_title_mode, TitleMode.ALL_INDEX));
        setBadgeSize(typedArray.getDimension(R.styleable.NavigationTabBar_ntb_badge_size, AUTO_SIZE));
        setBadgePosition(
                typedArray.getInt(R.styleable.NavigationTabBar_ntb_badge_position, BadgePosition.RIGHT_INDEX));
        setBadgeGravity(
                typedArray.getInt(R.styleable.NavigationTabBar_ntb_badge_gravity, BadgeGravity.TOP_INDEX));
        setBadgeBgColor(typedArray.getColor(R.styleable.NavigationTabBar_ntb_badge_bg_color, AUTO_COLOR));
        setBadgeTitleColor(typedArray.getColor(R.styleable.NavigationTabBar_ntb_badge_title_color, AUTO_COLOR));

        setTypeface(typedArray.getString(R.styleable.NavigationTabBar_ntb_typeface));
        setInactiveColor(
                typedArray.getColor(R.styleable.NavigationTabBar_ntb_inactive_color, DEFAULT_INACTIVE_COLOR));
        setActiveColor(
                typedArray.getColor(R.styleable.NavigationTabBar_ntb_active_color, DEFAULT_ACTIVE_COLOR));
        setBgColor(typedArray.getColor(R.styleable.NavigationTabBar_ntb_bg_color, DEFAULT_BG_COLOR));
        setAnimationDuration(typedArray.getInteger(R.styleable.NavigationTabBar_ntb_animation_duration,
                DEFAULT_ANIMATION_DURATION));
        setCornersRadius(typedArray.getDimension(R.styleable.NavigationTabBar_ntb_corners_radius, 0.0F));
        setIconSizeFraction(
                typedArray.getFloat(R.styleable.NavigationTabBar_ntb_icon_size_fraction, AUTO_SCALE));

        // Init animator
        mAnimator.setFloatValues(MIN_FRACTION, MAX_FRACTION);
        mAnimator.setInterpolator(new LinearInterpolator());
        mAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
            @Override
            public void onAnimationUpdate(final ValueAnimator animation) {
                updateIndicatorPosition((Float) animation.getAnimatedValue());
            }
        });

        // Set preview models
        if (isInEditMode()) {
            // Get preview colors
            String[] previewColors = null;
            try {
                final int previewColorsId = typedArray
                        .getResourceId(R.styleable.NavigationTabBar_ntb_preview_colors, 0);
                previewColors = previewColorsId == 0 ? null
                        : typedArray.getResources().getStringArray(previewColorsId);
            } catch (Exception exception) {
                previewColors = null;
                exception.printStackTrace();
            } finally {
                if (previewColors == null)
                    previewColors = typedArray.getResources().getStringArray(R.array.default_preview);

                for (String previewColor : previewColors)
                    mModels.add(new Model.Builder(null, Color.parseColor(previewColor)).build());
                requestLayout();
            }
        }
    } finally {
        typedArray.recycle();
    }
}

From source file:com.cocoa.cocoautils.widget.navigationtabbar.ntb.NavigationTabBar.java

@SuppressWarnings("ResourceAsColor")
public NavigationTabBar(final Context context, final AttributeSet attrs, final int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    //Init NTB/*from ww  w .jav  a  2  s.c  om*/

    // Always draw
    setWillNotDraw(false);
    // Speed and fix for pre 17 API
    ViewCompat.setLayerType(this, ViewCompat.LAYER_TYPE_SOFTWARE, null);
    setLayerType(LAYER_TYPE_SOFTWARE, null);

    final TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.NavigationTabBar);
    try {
        setIsTitled(typedArray.getBoolean(R.styleable.NavigationTabBar_ntb_titled, false));
        setIsBadged(typedArray.getBoolean(R.styleable.NavigationTabBar_ntb_badged, false));
        setIsScaled(typedArray.getBoolean(R.styleable.NavigationTabBar_ntb_scaled, true));
        setIsTinted(typedArray.getBoolean(R.styleable.NavigationTabBar_ntb_tinted, true));
        setIsSwiped(typedArray.getBoolean(R.styleable.NavigationTabBar_ntb_swiped, true));
        setTitleSize(typedArray.getDimension(R.styleable.NavigationTabBar_ntb_title_size, -2f));
        setIsBadgeUseTypeface(
                typedArray.getBoolean(R.styleable.NavigationTabBar_ntb_badge_use_typeface, false));

        setTitleMode(typedArray.getInt(R.styleable.NavigationTabBar_ntb_title_mode, TitleMode.ALL_INDEX));
        setBadgeSize(typedArray.getDimension(R.styleable.NavigationTabBar_ntb_badge_size, -2f));
        setBadgePosition(
                typedArray.getInt(R.styleable.NavigationTabBar_ntb_badge_position, BadgePosition.RIGHT_INDEX));
        setBadgeGravity(
                typedArray.getInt(R.styleable.NavigationTabBar_ntb_badge_gravity, BadgeGravity.TOP_INDEX));
        setBadgeBgColor(typedArray.getColor(R.styleable.NavigationTabBar_ntb_badge_bg_color, AUTO_COLOR));
        setBadgeTitleColor(typedArray.getColor(R.styleable.NavigationTabBar_ntb_badge_title_color, AUTO_COLOR));

        setTypeface(typedArray.getString(R.styleable.NavigationTabBar_ntb_typeface));
        setInactiveColor(
                typedArray.getColor(R.styleable.NavigationTabBar_ntb_inactive_color, DEFAULT_INACTIVE_COLOR));
        setActiveColor(
                typedArray.getColor(R.styleable.NavigationTabBar_ntb_active_color, DEFAULT_ACTIVE_COLOR));
        setBgColor(typedArray.getColor(R.styleable.NavigationTabBar_ntb_bg_color, DEFAULT_BG_COLOR));
        setAnimationDuration(typedArray.getInteger(R.styleable.NavigationTabBar_ntb_animation_duration,
                DEFAULT_ANIMATION_DURATION));
        setCornersRadius(typedArray.getDimension(R.styleable.NavigationTabBar_ntb_corners_radius, 0.0F));
        setIconSizeFraction(
                typedArray.getFloat(R.styleable.NavigationTabBar_ntb_icon_size_fraction, AUTO_SCALE));

        // Init animator
        mAnimator.setFloatValues(MIN_FRACTION, MAX_FRACTION);
        mAnimator.setInterpolator(new LinearInterpolator());
        mAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
            @Override
            public void onAnimationUpdate(final ValueAnimator animation) {
                updateIndicatorPosition((Float) animation.getAnimatedValue());
            }
        });

        // Set preview models
        if (isInEditMode()) {
            // Get preview colors
            String[] previewColors = null;
            try {
                final int previewColorsId = typedArray
                        .getResourceId(R.styleable.NavigationTabBar_ntb_preview_colors, 0);
                previewColors = previewColorsId == 0 ? null
                        : typedArray.getResources().getStringArray(previewColorsId);
            } catch (Exception exception) {
                previewColors = null;
                exception.printStackTrace();
            } finally {
                if (previewColors == null)
                    previewColors = typedArray.getResources().getStringArray(R.array.default_preview);

                for (String previewColor : previewColors)
                    mModels.add(new Model.Builder(null, Color.parseColor(previewColor)).build());
                requestLayout();
            }
        }
    } finally {
        typedArray.recycle();
    }
}

From source file:devlight.io.library.ntb.NavigationTabBar.java

@SuppressWarnings({ "ResourceAsColor", "ResourceType" })
public NavigationTabBar(final Context context, final AttributeSet attrs, final int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    //Init NTB// w ww. ja v  a 2s .  c  om

    // Always draw
    setWillNotDraw(false);
    // Speed and fix for pre 17 API
    ViewCompat.setLayerType(this, ViewCompat.LAYER_TYPE_SOFTWARE, null);
    setLayerType(LAYER_TYPE_SOFTWARE, null);

    final TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.NavigationTabBar);
    try {
        setIsTitled(typedArray.getBoolean(R.styleable.NavigationTabBar_ntb_titled, false));
        setIsBadged(typedArray.getBoolean(R.styleable.NavigationTabBar_ntb_badged, false));
        setIsScaled(typedArray.getBoolean(R.styleable.NavigationTabBar_ntb_scaled, true));
        setIsTinted(typedArray.getBoolean(R.styleable.NavigationTabBar_ntb_tinted, true));
        setIsSwiped(typedArray.getBoolean(R.styleable.NavigationTabBar_ntb_swiped, true));
        setTitleSize(typedArray.getDimension(R.styleable.NavigationTabBar_ntb_title_size, AUTO_SIZE));
        setIsBadgeUseTypeface(
                typedArray.getBoolean(R.styleable.NavigationTabBar_ntb_badge_use_typeface, false));

        setTitleMode(typedArray.getInt(R.styleable.NavigationTabBar_ntb_title_mode, TitleMode.ALL_INDEX));
        setBadgeSize(typedArray.getDimension(R.styleable.NavigationTabBar_ntb_badge_size, AUTO_SIZE));
        setBadgePosition(
                typedArray.getInt(R.styleable.NavigationTabBar_ntb_badge_position, BadgePosition.RIGHT_INDEX));
        setBadgeGravity(
                typedArray.getInt(R.styleable.NavigationTabBar_ntb_badge_gravity, BadgeGravity.TOP_INDEX));
        setBadgeBgColor(typedArray.getColor(R.styleable.NavigationTabBar_ntb_badge_bg_color, AUTO_COLOR));
        setBadgeTitleColor(typedArray.getColor(R.styleable.NavigationTabBar_ntb_badge_title_color, AUTO_COLOR));

        setTypeface(typedArray.getString(R.styleable.NavigationTabBar_ntb_typeface));
        setInactiveColor(
                typedArray.getColor(R.styleable.NavigationTabBar_ntb_inactive_color, DEFAULT_INACTIVE_COLOR));
        setActiveColor(
                typedArray.getColor(R.styleable.NavigationTabBar_ntb_active_color, DEFAULT_ACTIVE_COLOR));
        setBgColor(typedArray.getColor(R.styleable.NavigationTabBar_ntb_bg_color, DEFAULT_BG_COLOR));
        setAnimationDuration(typedArray.getInteger(R.styleable.NavigationTabBar_ntb_animation_duration,
                DEFAULT_ANIMATION_DURATION));
        setCornersRadius(typedArray.getDimension(R.styleable.NavigationTabBar_ntb_corners_radius, 0.0F));
        setIconSizeFraction(
                typedArray.getFloat(R.styleable.NavigationTabBar_ntb_icon_size_fraction, AUTO_SCALE));

        // Init animator
        mAnimator.setFloatValues(MIN_FRACTION, MAX_FRACTION);
        mAnimator.setInterpolator(new LinearInterpolator());
        mAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
            @Override
            public void onAnimationUpdate(final ValueAnimator animation) {
                updateIndicatorPosition((Float) animation.getAnimatedValue());
            }
        });

        // Set preview models
        if (isInEditMode()) {
            // Get preview colors
            String[] previewColors = null;
            try {
                final int previewColorsId = typedArray
                        .getResourceId(R.styleable.NavigationTabBar_ntb_preview_colors, 0);
                previewColors = previewColorsId == 0 ? null
                        : typedArray.getResources().getStringArray(previewColorsId);
            } catch (Exception exception) {
                previewColors = null;
                exception.printStackTrace();
            } finally {
                if (previewColors == null)
                    previewColors = typedArray.getResources().getStringArray(R.array.default_preview);

                for (String previewColor : previewColors)
                    mModels.add(new Model.Builder(null, Color.parseColor(previewColor)).build());
                requestLayout();
            }
        }
    } finally {
        typedArray.recycle();
    }
}

From source file:org.akop.ararat.view.CrosswordView.java

public CrosswordView(Context context, AttributeSet attrs) {
    super(context, attrs);

    if (!isInEditMode()) {
        setLayerType(View.LAYER_TYPE_HARDWARE, null);
    }/* w  ww .  j  av a2  s . c o  m*/

    // Set drawing defaults
    Resources r = context.getResources();
    DisplayMetrics dm = r.getDisplayMetrics();

    int cellFillColor = NORMAL_CELL_FILL_COLOR;
    int cheatedCellFillColor = CHEATED_CELL_FILL_COLOR;
    int mistakeCellFillColor = MISTAKE_CELL_FILL_COLOR;
    int selectedWordFillColor = SELECTED_WORD_FILL_COLOR;
    int selectedCellFillColor = SELECTED_CELL_FILL_COLOR;
    int markedCellFillColor = MARKED_CELL_FILL_COLOR;
    int numberTextColor = NUMBER_TEXT_COLOR;
    int cellStrokeColor = CELL_STROKE_COLOR;
    int circleStrokeColor = CIRCLE_STROKE_COLOR;
    int answerTextColor = ANSWER_TEXT_COLOR;

    mScaledDensity = dm.scaledDensity;
    float numberTextSize = NUMBER_TEXT_SIZE * mScaledDensity;
    mAnswerTextSize = ANSWER_TEXT_SIZE * mScaledDensity;

    mCellSize = CELL_SIZE * dm.density;
    mNumberTextPadding = NUMBER_TEXT_PADDING * dm.density;
    mIsEditable = true;
    mInputMode = INPUT_MODE_KEYBOARD;
    mSkipOccupiedOnType = false;
    mSelectFirstUnoccupiedOnNav = true;
    mMaxBitmapSize = DEFAULT_MAX_BITMAP_DIMENSION;

    // Read supplied attributes
    if (attrs != null) {
        Resources.Theme theme = context.getTheme();
        TypedArray a = theme.obtainStyledAttributes(attrs, R.styleable.CrosswordView, 0, 0);

        mCellSize = a.getDimension(R.styleable.CrosswordView_cellSize, mCellSize);
        mNumberTextPadding = a.getDimension(R.styleable.CrosswordView_numberTextPadding, mNumberTextPadding);
        numberTextSize = a.getDimension(R.styleable.CrosswordView_numberTextSize, numberTextSize);
        mAnswerTextSize = a.getDimension(R.styleable.CrosswordView_answerTextSize, mAnswerTextSize);
        answerTextColor = a.getColor(R.styleable.CrosswordView_answerTextColor, answerTextColor);
        cellFillColor = a.getColor(R.styleable.CrosswordView_defaultCellFillColor, cellFillColor);
        cheatedCellFillColor = a.getColor(R.styleable.CrosswordView_cheatedCellFillColor, cheatedCellFillColor);
        mistakeCellFillColor = a.getColor(R.styleable.CrosswordView_mistakeCellFillColor, mistakeCellFillColor);
        selectedWordFillColor = a.getColor(R.styleable.CrosswordView_selectedWordFillColor,
                selectedWordFillColor);
        selectedCellFillColor = a.getColor(R.styleable.CrosswordView_selectedCellFillColor,
                selectedCellFillColor);
        markedCellFillColor = a.getColor(R.styleable.CrosswordView_markedCellFillColor, markedCellFillColor);
        cellStrokeColor = a.getColor(R.styleable.CrosswordView_cellStrokeColor, cellStrokeColor);
        circleStrokeColor = a.getColor(R.styleable.CrosswordView_circleStrokeColor, circleStrokeColor);
        numberTextColor = a.getColor(R.styleable.CrosswordView_numberTextColor, numberTextColor);
        mIsEditable = a.getBoolean(R.styleable.CrosswordView_editable, mIsEditable);
        mSkipOccupiedOnType = a.getBoolean(R.styleable.CrosswordView_skipOccupiedOnType, mSkipOccupiedOnType);
        mSelectFirstUnoccupiedOnNav = a.getBoolean(R.styleable.CrosswordView_selectFirstUnoccupiedOnNav,
                mSelectFirstUnoccupiedOnNav);

        a.recycle();
    }

    mRevealSetsCheatFlag = true;
    mMarkerSideLength = mCellSize * MARKER_TRIANGLE_LENGTH_FRACTION;

    // Init paints
    mCellFillPaint = new Paint();
    mCellFillPaint.setColor(cellFillColor);
    mCellFillPaint.setStyle(Paint.Style.FILL);

    mCheatedCellFillPaint = new Paint();
    mCheatedCellFillPaint.setColor(cheatedCellFillColor);
    mCheatedCellFillPaint.setStyle(Paint.Style.FILL);

    mMistakeCellFillPaint = new Paint();
    mMistakeCellFillPaint.setColor(mistakeCellFillColor);
    mMistakeCellFillPaint.setStyle(Paint.Style.FILL);

    mSelectedWordFillPaint = new Paint();
    mSelectedWordFillPaint.setColor(selectedWordFillColor);
    mSelectedWordFillPaint.setStyle(Paint.Style.FILL);

    mSelectedCellFillPaint = new Paint();
    mSelectedCellFillPaint.setColor(selectedCellFillColor);
    mSelectedCellFillPaint.setStyle(Paint.Style.FILL);

    mMarkedCellFillPaint = new Paint();
    mMarkedCellFillPaint.setColor(markedCellFillColor);
    mMarkedCellFillPaint.setStyle(Paint.Style.FILL);

    mCellStrokePaint = new Paint();
    mCellStrokePaint.setColor(cellStrokeColor);
    mCellStrokePaint.setStyle(Paint.Style.STROKE);
    //      mCellStrokePaint.setStrokeWidth(1);

    mCircleStrokePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mCircleStrokePaint.setColor(circleStrokeColor);
    mCircleStrokePaint.setStyle(Paint.Style.STROKE);
    mCircleStrokePaint.setStrokeWidth(1);

    mNumberTextPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mNumberTextPaint.setColor(numberTextColor);
    mNumberTextPaint.setTextAlign(Paint.Align.CENTER);
    mNumberTextPaint.setTextSize(numberTextSize);

    // Compute number height
    mNumberTextPaint.getTextBounds("0", 0, "0".length(), mTempRect);
    mNumberTextHeight = mTempRect.height();

    mNumberStrokePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mNumberStrokePaint.setColor(cellFillColor);
    mNumberStrokePaint.setTextAlign(Paint.Align.CENTER);
    mNumberStrokePaint.setTextSize(numberTextSize);
    mNumberStrokePaint.setStyle(Paint.Style.STROKE);
    mNumberStrokePaint.setStrokeWidth(NUMBER_TEXT_STROKE_WIDTH * mScaledDensity);

    mAnswerTextPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mAnswerTextPaint.setColor(answerTextColor);
    mAnswerTextPaint.setTextSize(mAnswerTextSize);

    // Init rest of the values
    mCircleRadius = (mCellSize / 2) - mCircleStrokePaint.getStrokeWidth();
    mPuzzleCells = EMPTY_CELLS;
    mPuzzleWidth = 0;
    mPuzzleHeight = 0;
    mAllowedChars = EMPTY_CHARS;

    mRenderScale = 0;
    mBitmapOffset = new PointF();
    mCenteredOffset = new PointF();
    mTranslationBounds = new RectF();

    mScaleDetector = new ScaleGestureDetector(context, new ScaleListener());
    mGestureDetector = new GestureDetector(context, new GestureListener());

    mContentRect = new RectF();
    mPuzzleRect = new RectF();

    mBitmapPaint = new Paint(Paint.FILTER_BITMAP_FLAG);

    mScroller = new Scroller(context, null, true);
    mZoomer = new Zoomer(context);
    mUndoBuffer = new Stack<>();

    setFocusableInTouchMode(mIsEditable && mInputMode != INPUT_MODE_NONE);
    setOnKeyListener(this);
}

From source file:com.mci.firstidol.view.ActionSheet.java

private Attributes readAttribute() {
    Attributes attrs = new Attributes(getActivity());
    TypedArray a = getActivity().getTheme().obtainStyledAttributes(null, R.styleable.ActionSheet,
            R.attr.actionSheetStyle, 0);
    Drawable background = a.getDrawable(R.styleable.ActionSheet_actionSheetBackground);
    if (background != null) {
        attrs.background = background;/*from w  w w . j  a  v  a 2s .com*/
    }
    Drawable cancelButtonBackground = a.getDrawable(R.styleable.ActionSheet_cancelButtonBackground);
    if (cancelButtonBackground != null) {
        attrs.cancelButtonBackground = cancelButtonBackground;
    }
    Drawable otherButtonTopBackground = a.getDrawable(R.styleable.ActionSheet_otherButtonTopBackground);
    if (otherButtonTopBackground != null) {
        attrs.otherButtonTopBackground = otherButtonTopBackground;
    }
    Drawable otherButtonMiddleBackground = a.getDrawable(R.styleable.ActionSheet_otherButtonMiddleBackground);
    if (otherButtonMiddleBackground != null) {
        attrs.otherButtonMiddleBackground = otherButtonMiddleBackground;
    }
    Drawable otherButtonBottomBackground = a.getDrawable(R.styleable.ActionSheet_otherButtonBottomBackground);
    if (otherButtonBottomBackground != null) {
        attrs.otherButtonBottomBackground = otherButtonBottomBackground;
    }
    Drawable otherButtonSingleBackground = a.getDrawable(R.styleable.ActionSheet_otherButtonSingleBackground);
    if (otherButtonSingleBackground != null) {
        attrs.otherButtonSingleBackground = otherButtonSingleBackground;
    }

    Drawable actionSheetTitleBackground = a.getDrawable(R.styleable.ActionSheet_titleTXTBackground);
    if (actionSheetTitleBackground != null) {
        attrs.actionSheetTitleBackground = actionSheetTitleBackground;
    }

    attrs.cancelButtonTextColor = a.getColor(R.styleable.ActionSheet_cancelButtonTextColor,
            attrs.cancelButtonTextColor);
    attrs.otherButtonTextColor = a.getColor(R.styleable.ActionSheet_otherButtonTextColor,
            attrs.otherButtonTextColor);
    attrs.padding = (int) a.getDimension(R.styleable.ActionSheet_actionSheetPadding, attrs.padding);
    attrs.otherButtonSpacing = (int) a.getDimension(R.styleable.ActionSheet_otherButtonSpacing,
            attrs.otherButtonSpacing);
    attrs.cancelButtonMarginTop = (int) a.getDimension(R.styleable.ActionSheet_cancelButtonMarginTop,
            attrs.cancelButtonMarginTop);
    attrs.actionSheetTextSize = a.getDimensionPixelSize(R.styleable.ActionSheet_actionSheetTextSize,
            (int) attrs.actionSheetTextSize);

    a.recycle();
    return attrs;
}

From source file:co.ceryle.segmentedbutton.SegmentedButtonGroup.java

/**
 * Get attributes//from w ww  .j  a va 2  s .  c o m
 **/
private void getAttributes(AttributeSet attrs) {
    TypedArray typedArray = getContext().obtainStyledAttributes(attrs, R.styleable.SegmentedButtonGroup);

    hasDivider = typedArray.hasValue(R.styleable.SegmentedButtonGroup_sbg_dividerSize);
    dividerSize = typedArray.getDimensionPixelSize(R.styleable.SegmentedButtonGroup_sbg_dividerSize, 0);
    dividerColor = typedArray.getColor(R.styleable.SegmentedButtonGroup_sbg_dividerColor, Color.WHITE);
    dividerPadding = typedArray.getDimensionPixelSize(R.styleable.SegmentedButtonGroup_sbg_dividerPadding, 0);
    dividerRadius = typedArray.getDimensionPixelSize(R.styleable.SegmentedButtonGroup_sbg_dividerRadius, 0);

    textColorOnSelection = typedArray.getColor(R.styleable.SegmentedButtonGroup_sbg_selectorTextColor,
            Color.GRAY);
    hasTextColorOnSelection = typedArray.hasValue(R.styleable.SegmentedButtonGroup_sbg_selectorTextColor);
    drawableTintOnSelection = typedArray.getColor(R.styleable.SegmentedButtonGroup_sbg_selectorImageTint,
            Color.GRAY);
    hasDrawableTintOnSelection = typedArray.hasValue(R.styleable.SegmentedButtonGroup_sbg_selectorImageTint);
    selectorColor = typedArray.getColor(R.styleable.SegmentedButtonGroup_sbg_selectorColor, Color.GRAY);
    animateSelector = typedArray.getInt(R.styleable.SegmentedButtonGroup_sbg_animateSelector, 0);
    animateSelectorDuration = typedArray.getInt(R.styleable.SegmentedButtonGroup_sbg_animateSelectorDuration,
            500);

    shadow = typedArray.getBoolean(R.styleable.SegmentedButtonGroup_sbg_shadow, false);
    shadowElevation = typedArray.getDimension(R.styleable.SegmentedButtonGroup_sbg_shadowElevation, 0);
    shadowMargin = typedArray.getDimensionPixelSize(R.styleable.SegmentedButtonGroup_sbg_shadowMargin, -1);
    shadowMarginTop = typedArray.getDimensionPixelSize(R.styleable.SegmentedButtonGroup_sbg_shadowMarginTop, 0);
    shadowMarginBottom = typedArray
            .getDimensionPixelSize(R.styleable.SegmentedButtonGroup_sbg_shadowMarginBottom, 0);
    shadowMarginLeft = typedArray.getDimensionPixelSize(R.styleable.SegmentedButtonGroup_sbg_shadowMarginLeft,
            0);
    shadowMarginRight = typedArray.getDimensionPixelSize(R.styleable.SegmentedButtonGroup_sbg_shadowMarginRight,
            0);

    radius = typedArray.getDimension(R.styleable.SegmentedButtonGroup_sbg_radius, 0);
    position = typedArray.getInt(R.styleable.SegmentedButtonGroup_sbg_position, 0);
    backgroundColor = typedArray.getColor(R.styleable.SegmentedButtonGroup_sbg_backgroundColor, Color.WHITE);

    ripple = typedArray.getBoolean(R.styleable.SegmentedButtonGroup_sbg_ripple, false);
    hasRippleColor = typedArray.hasValue(R.styleable.SegmentedButtonGroup_sbg_rippleColor);
    rippleColor = typedArray.getColor(R.styleable.SegmentedButtonGroup_sbg_rippleColor, Color.GRAY);

    borderSize = typedArray.getDimensionPixelSize(R.styleable.SegmentedButtonGroup_sbg_borderSize, 0);
    borderColor = typedArray.getColor(R.styleable.SegmentedButtonGroup_sbg_borderColor, Color.BLACK);

    backgroundDrawable = typedArray.getDrawable(R.styleable.SegmentedButtonGroup_sbg_backgroundDrawable);
    selectorBackgroundDrawable = typedArray
            .getDrawable(R.styleable.SegmentedButtonGroup_sbg_selectorBackgroundDrawable);
    dividerBackgroundDrawable = typedArray
            .getDrawable(R.styleable.SegmentedButtonGroup_sbg_dividerBackgroundDrawable);

    enabled = typedArray.getBoolean(R.styleable.SegmentedButtonGroup_sbg_enabled, true);

    try {
        clickable = typedArray.getBoolean(R.styleable.SegmentedButtonGroup_android_clickable, true);
    } catch (Exception ex) {
        Log.d("SegmentedButtonGroup", ex.toString());
    }

    typedArray.recycle();
}

From source file:info.awesomedevelopment.tvgrid.library.TVGridView.java

@SuppressWarnings("deprecation")
private void init(AttributeSet attrs) {
    ActivityManager am = (ActivityManager) getContext().getSystemService(Context.ACTIVITY_SERVICE);
    mCache = new LruCache<>(am.getMemoryClass() * 1024);

    mYSize = new ValueAnimator();
    mXSize = new ValueAnimator();
    mYLocation = new ValueAnimator();
    mXLocation = new ValueAnimator();

    mXSize.addUpdateListener(xSizeListener);
    mYSize.addUpdateListener(ySizeListener);
    mYLocation.addUpdateListener(yLocationListener);
    mXLocation.addUpdateListener(xLocationListener);

    mSelectorAnimationSet.playTogether(mXLocation, mYLocation, mXSize, mYSize);
    mSelectorAnimationSet.setInterpolator(new AccelerateDecelerateInterpolator());
    mSelectorAnimationSet.setDuration(ANIMATION_DURATION);

    TypedValue fillAlpha = new TypedValue();
    getResources().getValue(R.dimen.tvg_defFillAlpha, fillAlpha, true);

    TypedValue fillAlphaSelected = new TypedValue();
    getResources().getValue(R.dimen.tvg_defFillAlphaSelected, fillAlphaSelected, true);

    if (attrs != null) {
        TypedArray a = getContext().getTheme().obtainStyledAttributes(attrs, R.styleable.TVGridView, 0, 0);

        try {/* w ww . j a  va  2  s.  c  om*/
            //noinspection ResourceType
            mStrokePosition = a.getInteger(R.styleable.TVGridView_tvg_strokePosition, OUTSIDE);
            //noinspection ResourceType
            mSelectorPosition = a.getInteger(R.styleable.TVGridView_tvg_selectorPosition, OVER);
            //noinspection ResourceType
            mSelectorShape = a.getInteger(R.styleable.TVGridView_tvg_selectorShape, RECTANGLE);

            mAnimateSelectorChanges = a.getBoolean(R.styleable.TVGridView_tvg_animateSelectorChanges,
                    getResources().getInteger(R.integer.tvg_defAnimateSelectorChanges) == 1);
            mIsFilled = a.getBoolean(R.styleable.TVGridView_tvg_filled,
                    getResources().getInteger(R.integer.tvg_defIsFilled) == 1);
            mFillAlpha = a.getFloat(R.styleable.TVGridView_tvg_fillAlpha, fillAlpha.getFloat());
            mFillAlphaSelected = a.getFloat(R.styleable.TVGridView_tvg_fillAlphaSelected,
                    fillAlphaSelected.getFloat());
            mFillColor = a.getColor(R.styleable.TVGridView_tvg_fillColor,
                    getResources().getColor(R.color.tvg_defFillColor));
            mFillColorSelected = a.getColor(R.styleable.TVGridView_tvg_fillColorSelected,
                    getResources().getColor(R.color.tvg_defFillColorSelected));
            mCornerRadiusX = a.getDimension(R.styleable.TVGridView_tvg_cornerRadius,
                    getResources().getDimension(R.dimen.tvg_defCornerRadius));
            mCornerRadiusY = a.getDimension(R.styleable.TVGridView_tvg_cornerRadius,
                    getResources().getDimension(R.dimen.tvg_defCornerRadius));
            mStrokeWidth = a.getDimension(R.styleable.TVGridView_tvg_strokeWidth,
                    getResources().getDimension(R.dimen.tvg_defStrokeWidth));
            mStrokeColor = a.getColor(R.styleable.TVGridView_tvg_strokeColor,
                    getResources().getColor(R.color.tvg_defStrokeColor));
            mStrokeColorSelected = a.getColor(R.styleable.TVGridView_tvg_strokeColorSelected,
                    getResources().getColor(R.color.tvg_defStrokeColorSelected));
            mStrokeMarginLeft = a.getDimension(R.styleable.TVGridView_tvg_marginLeft,
                    getResources().getDimension(R.dimen.tvg_defStrokeMarginLeft));
            mStrokeMarginTop = a.getDimension(R.styleable.TVGridView_tvg_marginTop,
                    getResources().getDimension(R.dimen.tvg_defStrokeMarginTop));
            mStrokeMarginRight = a.getDimension(R.styleable.TVGridView_tvg_marginRight,
                    getResources().getDimension(R.dimen.tvg_defStrokeMarginRight));
            mStrokeMarginBottom = a.getDimension(R.styleable.TVGridView_tvg_marginBottom,
                    getResources().getDimension(R.dimen.tvg_defStrokeMarginBottom));
            mStrokeSpacingLeft = a.getDimension(R.styleable.TVGridView_tvg_spacingLeft,
                    getResources().getDimension(R.dimen.tvg_defStrokeSpacingLeft));
            mStrokeSpacingTop = a.getDimension(R.styleable.TVGridView_tvg_spacingTop,
                    getResources().getDimension(R.dimen.tvg_defStrokeSpacingTop));
            mStrokeSpacingRight = a.getDimension(R.styleable.TVGridView_tvg_spacingRight,
                    getResources().getDimension(R.dimen.tvg_defStrokeSpacingRight));
            mStrokeSpacingBottom = a.getDimension(R.styleable.TVGridView_tvg_spacingBottom,
                    getResources().getDimension(R.dimen.tvg_defStrokeSpacingBottom));
        } finally {
            a.recycle();
        }
    } else {
        mStrokePosition = OUTSIDE;
        mSelectorPosition = OVER;
        mSelectorShape = RECTANGLE;

        mAnimateSelectorChanges = getResources().getInteger(R.integer.tvg_defAnimateSelectorChanges) == 1;
        mIsFilled = getResources().getInteger(R.integer.tvg_defIsFilled) == 1;
        mFillAlpha = fillAlpha.getFloat();
        mFillAlphaSelected = fillAlphaSelected.getFloat();
        mFillColor = getResources().getColor(R.color.tvg_defFillColor);
        mFillColorSelected = getResources().getColor(R.color.tvg_defFillColorSelected);
        mCornerRadiusX = getResources().getDimension(R.dimen.tvg_defCornerRadius);
        mCornerRadiusY = getResources().getDimension(R.dimen.tvg_defCornerRadius);
        mStrokeWidth = getResources().getDimension(R.dimen.tvg_defStrokeWidth);
        mStrokeColor = getResources().getColor(R.color.tvg_defStrokeColor);
        mStrokeColorSelected = getResources().getColor(R.color.tvg_defStrokeColorSelected);
        mStrokeMarginLeft = getResources().getDimension(R.dimen.tvg_defStrokeMarginLeft);
        mStrokeMarginTop = getResources().getDimension(R.dimen.tvg_defStrokeMarginTop);
        mStrokeMarginRight = getResources().getDimension(R.dimen.tvg_defStrokeMarginRight);
        mStrokeMarginBottom = getResources().getDimension(R.dimen.tvg_defStrokeMarginBottom);
        mStrokeSpacingLeft = getResources().getDimension(R.dimen.tvg_defStrokeSpacingLeft);
        mStrokeSpacingTop = getResources().getDimension(R.dimen.tvg_defStrokeSpacingTop);
        mStrokeSpacingRight = getResources().getDimension(R.dimen.tvg_defStrokeSpacingRight);
        mStrokeSpacingBottom = getResources().getDimension(R.dimen.tvg_defStrokeSpacingBottom);
    }

    addOnScrollListener(new OnScrollListener() {
        @Override
        public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
            super.onScrollStateChanged(recyclerView, newState);
            if (newState == SCROLL_STATE_IDLE) {
                mEdgeChange = false;
                mHardScrollChange = false;
            }
        }

        @Override
        public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
            super.onScrolled(recyclerView, dx, dy);
            mScrollY = mScrollY + dy;

            if (mStrokeCellCurrentBounds == null || mStrokeCell == null)
                return;

            if (useAnimations()) {
                mSelectorAnimationSet.cancel();

                mStrokeCellCurrentBounds.offsetTo(mStrokeCellCurrentBounds.left - dx,
                        mStrokeCellCurrentBounds.top - dy);

                performSelectorAnimation();
            } else if (mHardScrollChange || mEdgeChange) {
                mStrokeCellCurrentBounds.offsetTo(mStrokeCellCurrentBounds.left - dx,
                        mStrokeCellCurrentBounds.top - dy);
                setPrevBounds();

                mStrokeCell.setBounds(mStrokeCellPrevBounds);
                invalidate();
            }
        }
    });

    setOnTouchListener(new OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            clearHighlightedView();
            return false;
        }
    });
}

From source file:android.support.graphics.drawable.AnimatorInflaterCompat.java

private static PropertyValuesHolder getPVH(TypedArray styledAttributes, int valueType, int valueFromId,
        int valueToId, String propertyName) {

    TypedValue tvFrom = styledAttributes.peekValue(valueFromId);
    boolean hasFrom = (tvFrom != null);
    int fromType = hasFrom ? tvFrom.type : 0;
    TypedValue tvTo = styledAttributes.peekValue(valueToId);
    boolean hasTo = (tvTo != null);
    int toType = hasTo ? tvTo.type : 0;

    if (valueType == VALUE_TYPE_UNDEFINED) {
        // Check whether it's color type. If not, fall back to default type (i.e. float type)
        if ((hasFrom && isColorType(fromType)) || (hasTo && isColorType(toType))) {
            valueType = VALUE_TYPE_COLOR;
        } else {/*from w w  w.j  a  v a  2 s  . c  o  m*/
            valueType = VALUE_TYPE_FLOAT;
        }
    }

    boolean getFloats = (valueType == VALUE_TYPE_FLOAT);

    PropertyValuesHolder returnValue = null;

    if (valueType == VALUE_TYPE_PATH) {
        String fromString = styledAttributes.getString(valueFromId);
        String toString = styledAttributes.getString(valueToId);

        PathParser.PathDataNode[] nodesFrom = PathParser.createNodesFromPathData(fromString);
        PathParser.PathDataNode[] nodesTo = PathParser.createNodesFromPathData(toString);
        if (nodesFrom != null || nodesTo != null) {
            if (nodesFrom != null) {
                TypeEvaluator evaluator = new PathDataEvaluator();
                if (nodesTo != null) {
                    if (!PathParser.canMorph(nodesFrom, nodesTo)) {
                        throw new InflateException(" Can't morph from " + fromString + " to " + toString);
                    }
                    returnValue = PropertyValuesHolder.ofObject(propertyName, evaluator, nodesFrom, nodesTo);
                } else {
                    returnValue = PropertyValuesHolder.ofObject(propertyName, evaluator, (Object) nodesFrom);
                }
            } else if (nodesTo != null) {
                TypeEvaluator evaluator = new PathDataEvaluator();
                returnValue = PropertyValuesHolder.ofObject(propertyName, evaluator, (Object) nodesTo);
            }
        }
    } else {
        TypeEvaluator evaluator = null;
        // Integer and float value types are handled here.
        if (valueType == VALUE_TYPE_COLOR) {
            // special case for colors: ignore valueType and get ints
            evaluator = ArgbEvaluator.getInstance();
        }
        if (getFloats) {
            float valueFrom;
            float valueTo;
            if (hasFrom) {
                if (fromType == TypedValue.TYPE_DIMENSION) {
                    valueFrom = styledAttributes.getDimension(valueFromId, 0f);
                } else {
                    valueFrom = styledAttributes.getFloat(valueFromId, 0f);
                }
                if (hasTo) {
                    if (toType == TypedValue.TYPE_DIMENSION) {
                        valueTo = styledAttributes.getDimension(valueToId, 0f);
                    } else {
                        valueTo = styledAttributes.getFloat(valueToId, 0f);
                    }
                    returnValue = PropertyValuesHolder.ofFloat(propertyName, valueFrom, valueTo);
                } else {
                    returnValue = PropertyValuesHolder.ofFloat(propertyName, valueFrom);
                }
            } else {
                if (toType == TypedValue.TYPE_DIMENSION) {
                    valueTo = styledAttributes.getDimension(valueToId, 0f);
                } else {
                    valueTo = styledAttributes.getFloat(valueToId, 0f);
                }
                returnValue = PropertyValuesHolder.ofFloat(propertyName, valueTo);
            }
        } else {
            int valueFrom;
            int valueTo;
            if (hasFrom) {
                if (fromType == TypedValue.TYPE_DIMENSION) {
                    valueFrom = (int) styledAttributes.getDimension(valueFromId, 0f);
                } else if (isColorType(fromType)) {
                    valueFrom = styledAttributes.getColor(valueFromId, 0);
                } else {
                    valueFrom = styledAttributes.getInt(valueFromId, 0);
                }
                if (hasTo) {
                    if (toType == TypedValue.TYPE_DIMENSION) {
                        valueTo = (int) styledAttributes.getDimension(valueToId, 0f);
                    } else if (isColorType(toType)) {
                        valueTo = styledAttributes.getColor(valueToId, 0);
                    } else {
                        valueTo = styledAttributes.getInt(valueToId, 0);
                    }
                    returnValue = PropertyValuesHolder.ofInt(propertyName, valueFrom, valueTo);
                } else {
                    returnValue = PropertyValuesHolder.ofInt(propertyName, valueFrom);
                }
            } else {
                if (hasTo) {
                    if (toType == TypedValue.TYPE_DIMENSION) {
                        valueTo = (int) styledAttributes.getDimension(valueToId, 0f);
                    } else if (isColorType(toType)) {
                        valueTo = styledAttributes.getColor(valueToId, 0);
                    } else {
                        valueTo = styledAttributes.getInt(valueToId, 0);
                    }
                    returnValue = PropertyValuesHolder.ofInt(propertyName, valueTo);
                }
            }
        }
        if (returnValue != null && evaluator != null) {
            returnValue.setEvaluator(evaluator);
        }
    }

    return returnValue;
}

From source file:com.gigamole.library.NavigationTabBar.java

public NavigationTabBar(final Context context, final AttributeSet attrs, final int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    //Init NTB//from w ww .  j ava 2s . c  o  m

    // Always draw
    setWillNotDraw(false);
    // More speed!
    setLayerType(LAYER_TYPE_HARDWARE, null);

    final TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.NavigationTabBar);
    try {
        setIsTitled(typedArray.getBoolean(R.styleable.NavigationTabBar_ntb_titled, false));
        setIsBadged(typedArray.getBoolean(R.styleable.NavigationTabBar_ntb_badged, false));
        setIsBadgeUseTypeface(
                typedArray.getBoolean(R.styleable.NavigationTabBar_ntb_badge_use_typeface, false));
        setTitleMode(typedArray.getInt(R.styleable.NavigationTabBar_ntb_title_mode, ALL_INDEX));
        setBadgePosition(typedArray.getInt(R.styleable.NavigationTabBar_ntb_badge_position, RIGHT_INDEX));
        setBadgeGravity(typedArray.getInt(R.styleable.NavigationTabBar_ntb_badge_gravity, TOP_INDEX));
        setTypeface(typedArray.getString(R.styleable.NavigationTabBar_ntb_typeface));
        setInactiveColor(
                typedArray.getColor(R.styleable.NavigationTabBar_ntb_inactive_color, DEFAULT_INACTIVE_COLOR));
        setActiveColor(
                typedArray.getColor(R.styleable.NavigationTabBar_ntb_active_color, DEFAULT_ACTIVE_COLOR));
        setAnimationDuration(typedArray.getInteger(R.styleable.NavigationTabBar_ntb_animation_duration,
                DEFAULT_ANIMATION_DURATION));
        setCornersRadius(typedArray.getDimension(R.styleable.NavigationTabBar_ntb_corners_radius, 0.0f));

        // Init animator
        mAnimator.setFloatValues(MIN_FRACTION, MAX_FRACTION);
        mAnimator.setInterpolator(new LinearInterpolator());
        mAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
            @Override
            public void onAnimationUpdate(final ValueAnimator animation) {
                updateIndicatorPosition((Float) animation.getAnimatedValue());
            }
        });

        // Set preview models
        if (isInEditMode()) {
            // Get preview colors
            String[] previewColors = null;
            try {
                final int previewColorsId = typedArray
                        .getResourceId(R.styleable.NavigationTabBar_ntb_preview_colors, 0);
                previewColors = previewColorsId == 0 ? null
                        : typedArray.getResources().getStringArray(previewColorsId);
            } catch (Exception exception) {
                previewColors = null;
                exception.printStackTrace();
            } finally {
                if (previewColors == null)
                    previewColors = typedArray.getResources().getStringArray(R.array.default_preview);

                for (String previewColor : previewColors)
                    mModels.add(new Model(null, Color.parseColor(previewColor)));
                requestLayout();
            }
        }
    } finally {
        typedArray.recycle();
    }
}

From source file:com.viewsforandroid.foundry.sample.indicators.NumericPageIndicator.java

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

    // Load defaults from resources
    final Resources res = getResources();
    final int defaultTextColor = res.getColor(R.color.default_page_number_indicator_text_color);
    final int defaultPageNumberTextColor = res
            .getColor(R.color.default_page_number_indicator_page_number_text_color);
    final boolean defaultPageNumberTextBold = res
            .getBoolean(R.bool.default_page_number_indicator_page_number_text_bold);
    final int defaultButtonPressedColor = res
            .getColor(R.color.default_page_number_indicator_pressed_button_color);
    final float defaultTopPadding = res.getDimension(R.dimen.default_page_number_indicator_top_padding);
    final float defaultBottomPadding = res.getDimension(R.dimen.default_page_number_indicator_bottom_padding);
    final float defaultTextSize = res.getDimension(R.dimen.default_page_number_indicator_text_size);
    final boolean defaultShowChangePageButtons = res
            .getBoolean(R.bool.default_page_number_indicator_show_change_page_buttons);
    final boolean defaultShowStartEndButtons = res
            .getBoolean(R.bool.default_page_number_indicator_show_start_end_buttons);

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

    mTextTemplate = a.getString(R.styleable.NumericPageIndicator_textTemplate);
    if (mTextTemplate == null) {
        mTextTemplate = res.getString(R.string.default_page_number_indicator_text_template);
        ;
    }
    parseTextTemplate();

    mTextStartButton = a.getString(R.styleable.NumericPageIndicator_startButtonText);
    if (mTextStartButton == null) {
        mTextStartButton = res.getString(R.string.default_page_number_indicator_start_button_text);
    }
    mTextEndButton = a.getString(R.styleable.NumericPageIndicator_endButtonText);
    if (mTextEndButton == null) {
        mTextEndButton = res.getString(R.string.default_page_number_indicator_end_button_text);
    }
    mTextPreviousButton = a.getString(R.styleable.NumericPageIndicator_previousButtonText);
    if (mTextPreviousButton == null) {
        mTextPreviousButton = res.getString(R.string.default_page_number_indicator_previous_button_text);
    }
    mTextNextButton = a.getString(R.styleable.NumericPageIndicator_nextButtonText);
    if (mTextNextButton == null) {
        mTextNextButton = res.getString(R.string.default_page_number_indicator_next_button_text);
    }

    mColorText = a.getColor(R.styleable.NumericPageIndicator_android_textColor, defaultTextColor);
    mColorPageNumberText = a.getColor(R.styleable.NumericPageIndicator_pageNumberTextColor,
            defaultPageNumberTextColor);
    mPageNumberTextBold = a.getBoolean(R.styleable.NumericPageIndicator_pageNumberTextBold,
            defaultPageNumberTextBold);
    mColorPressedButton = a.getColor(R.styleable.NumericPageIndicator_pressedButtonColor,
            defaultButtonPressedColor);
    mPaddingTop = a.getDimension(R.styleable.NumericPageIndicator_android_paddingTop, defaultTopPadding);
    mPaddingBottom = a.getDimension(R.styleable.NumericPageIndicator_android_paddingBottom,
            defaultBottomPadding);
    mPaintText.setColor(mColorText);
    mShowChangePageButtons = a.getBoolean(R.styleable.NumericPageIndicator_showChangePageButtons,
            defaultShowChangePageButtons);
    mShowStartEndButtons = a.getBoolean(R.styleable.NumericPageIndicator_showStartEndButtons,
            defaultShowStartEndButtons);

    mPaintButtonBackground.setColor(mColorPressedButton);
    final float textSize = a.getDimension(R.styleable.NumericPageIndicator_android_textSize, defaultTextSize);
    mPaintText.setTextSize(textSize);
    mPaintText.setAntiAlias(true);

    mPaintPageNumberText.setColor(mColorPageNumberText);
    mPaintPageNumberText.setTextSize(textSize);
    mPaintPageNumberText.setAntiAlias(true);
    if (mPageNumberTextBold) {
        mPaintPageNumberText.setTypeface(Typeface.DEFAULT_BOLD);
    }

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

    a.recycle();
}