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.github.lakeshire.pageindicator.CirclePageIndicator.java

public CirclePageIndicator(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    if (isInEditMode())
        return;/*from  w ww. j a  v  a  2 s  .  c o  m*/

    //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);
    final float defaultExtraSpacing = res.getDimension(R.dimen.default_circle_indicator_extra_spacing);

    //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(a.getDimension(R.styleable.CirclePageIndicator_strokeWidth, 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);
    mExtraSpacing = a.getDimension(R.styleable.CirclePageIndicator_extraSpacing, defaultExtraSpacing);
    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.zhima.ui.common.view.CirclePageIndicator.java

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

    //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.vpiCirclePageIndicatorStyle, defStyle, 0);

    mCentered = a.getBoolean(R.styleable.vpiCirclePageIndicatorStyle_centered_spu, defaultCentered);
    mOrientation = a.getInt(R.styleable.vpiCirclePageIndicatorStyle_android_orientation, defaultOrientation);
    mPaintPageFill.setStyle(Style.FILL);
    mPaintPageFill.setColor(a.getColor(R.styleable.vpiCirclePageIndicatorStyle_pageColor, defaultPageColor));
    mPaintStroke.setStyle(Style.STROKE);
    mPaintStroke.setColor(a.getColor(R.styleable.vpiCirclePageIndicatorStyle_strokeColor, defaultStrokeColor));
    mPaintStroke.setStrokeWidth(
            a.getDimension(R.styleable.vpiCirclePageIndicatorStyle_strokeWidth, defaultStrokeWidth));
    mPaintFill.setStyle(Style.FILL);
    mPaintFill.setColor(a.getColor(R.styleable.vpiCirclePageIndicatorStyle_fillColor, defaultFillColor));
    mRadius = a.getDimension(R.styleable.vpiCirclePageIndicatorStyle_radius_sup, defaultRadius);
    mSnap = a.getBoolean(R.styleable.vpiCirclePageIndicatorStyle_snap, defaultSnap);

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

    a.recycle();

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

From source file:com.bestdo.bestdoStadiums.control.view.CirclePageIndicator.java

public CirclePageIndicator(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    this.context = context;
    if (isInEditMode())
        return;/*from   w  ww. java  2 s.  c  o m*/

    // 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(a.getDimension(R.styleable.CirclePageIndicator_strokeWidth, defaultStrokeWidth));
    mPaintFill.setStyle(Style.FILL);
    mPaintFill.setColor(a.getColor(R.styleable.CirclePageIndicator_fillColor, defaultFillColor));
    mRadius = a.getDimension(R.styleable.CirclePageIndicator_radius2, 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);

    /**
     * 
     */
    mPaintPageFill.setColor(context.getResources().getColor(R.color.text_noclick_color));
    mPaintStroke.setColor(context.getResources().getColor(R.color.transparent));
    mPaintStroke.setStrokeWidth(0.5f);
    mPaintFill.setColor(context.getResources().getColor(R.color.white));
}

From source file:pt.carlos.alex.rosario.ContasRosario.java

@SuppressWarnings("deprecation")
public ContasRosario(final Context context, final AttributeSet attrs, final int defStyle) {
    super(context, attrs, defStyle);
    if (isInEditMode()) {
        return;/*w w  w . j a v  a 2  s  .c om*/
    }

    //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(a.getDimension(R.styleable.CirclePageIndicator_strokeWidth, 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:net.fastvan.indicator.CirclePageIndicator.java

@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
public CirclePageIndicator(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    if (isInEditMode())
        return;/*from w w w  . j  av a 2 s.  co  m*/

    //        public static final int getColor(Context context, int id) {
    //            final int version = Build.VERSION.SDK_INT;
    //            if (version >= 23) {
    //                return ContextCompat.getColor(context, id);
    //            } else {
    //                return context.getResources().getColor(id);
    //            }
    //        }
    //Load defaults from resources
    final Resources res = context.getResources();

    final int defaultPageColor = ContextCompat.getColor(context, R.color.default_circle_indicator_page_color);

    final int defaultFillColor = ContextCompat.getColor(context, R.color.default_circle_indicator_fill_color);
    final int defaultOrientation = res.getInteger(R.integer.default_circle_indicator_orientation);
    final int defaultStrokeColor = ContextCompat.getColor(context,
            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(a.getDimension(R.styleable.CirclePageIndicator_strokeWidth, 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) {

        int sdk = android.os.Build.VERSION.SDK_INT;
        if (sdk < android.os.Build.VERSION_CODES.JELLY_BEAN) {
            setBackgroundDrawable(background);
        } else {
            setBackground(background);
        }
    }

    a.recycle();

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

From source file:android.support.v7.widget.AppCompatTextViewAutoSizeHelper.java

void loadFromAttributes(AttributeSet attrs, int defStyleAttr) {
    float autoSizeMinTextSizeInPx = UNSET_AUTO_SIZE_UNIFORM_CONFIGURATION_VALUE;
    float autoSizeMaxTextSizeInPx = UNSET_AUTO_SIZE_UNIFORM_CONFIGURATION_VALUE;
    float autoSizeStepGranularityInPx = UNSET_AUTO_SIZE_UNIFORM_CONFIGURATION_VALUE;

    TypedArray a = mContext.obtainStyledAttributes(attrs, R.styleable.AppCompatTextView, defStyleAttr, 0);
    if (a.hasValue(R.styleable.AppCompatTextView_autoSizeTextType)) {
        mAutoSizeTextType = a.getInt(R.styleable.AppCompatTextView_autoSizeTextType,
                TextViewCompat.AUTO_SIZE_TEXT_TYPE_NONE);
    }//from ww w. ja  v  a  2  s  .co m
    if (a.hasValue(R.styleable.AppCompatTextView_autoSizeStepGranularity)) {
        autoSizeStepGranularityInPx = a.getDimension(R.styleable.AppCompatTextView_autoSizeStepGranularity,
                UNSET_AUTO_SIZE_UNIFORM_CONFIGURATION_VALUE);
    }
    if (a.hasValue(R.styleable.AppCompatTextView_autoSizeMinTextSize)) {
        autoSizeMinTextSizeInPx = a.getDimension(R.styleable.AppCompatTextView_autoSizeMinTextSize,
                UNSET_AUTO_SIZE_UNIFORM_CONFIGURATION_VALUE);
    }
    if (a.hasValue(R.styleable.AppCompatTextView_autoSizeMaxTextSize)) {
        autoSizeMaxTextSizeInPx = a.getDimension(R.styleable.AppCompatTextView_autoSizeMaxTextSize,
                UNSET_AUTO_SIZE_UNIFORM_CONFIGURATION_VALUE);
    }
    if (a.hasValue(R.styleable.AppCompatTextView_autoSizePresetSizes)) {
        final int autoSizeStepSizeArrayResId = a
                .getResourceId(R.styleable.AppCompatTextView_autoSizePresetSizes, 0);
        if (autoSizeStepSizeArrayResId > 0) {
            final TypedArray autoSizePreDefTextSizes = a.getResources()
                    .obtainTypedArray(autoSizeStepSizeArrayResId);
            setupAutoSizeUniformPresetSizes(autoSizePreDefTextSizes);
            autoSizePreDefTextSizes.recycle();
        }
    }
    a.recycle();

    if (supportsAutoSizeText()) {
        if (mAutoSizeTextType == TextViewCompat.AUTO_SIZE_TEXT_TYPE_UNIFORM) {
            // If uniform auto-size has been specified but preset values have not been set then
            // replace the auto-size configuration values that have not been specified with the
            // defaults.
            if (!mHasPresetAutoSizeValues) {
                final DisplayMetrics displayMetrics = mContext.getResources().getDisplayMetrics();

                if (autoSizeMinTextSizeInPx == UNSET_AUTO_SIZE_UNIFORM_CONFIGURATION_VALUE) {
                    autoSizeMinTextSizeInPx = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP,
                            DEFAULT_AUTO_SIZE_MIN_TEXT_SIZE_IN_SP, displayMetrics);
                }

                if (autoSizeMaxTextSizeInPx == UNSET_AUTO_SIZE_UNIFORM_CONFIGURATION_VALUE) {
                    autoSizeMaxTextSizeInPx = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP,
                            DEFAULT_AUTO_SIZE_MAX_TEXT_SIZE_IN_SP, displayMetrics);
                }

                if (autoSizeStepGranularityInPx == UNSET_AUTO_SIZE_UNIFORM_CONFIGURATION_VALUE) {
                    autoSizeStepGranularityInPx = DEFAULT_AUTO_SIZE_GRANULARITY_IN_PX;
                }

                validateAndSetAutoSizeTextTypeUniformConfiguration(autoSizeMinTextSizeInPx,
                        autoSizeMaxTextSizeInPx, autoSizeStepGranularityInPx);
            }

            setupAutoSizeText();
        }
    } else {
        mAutoSizeTextType = TextViewCompat.AUTO_SIZE_TEXT_TYPE_NONE;
    }
}

From source file:com.common.view.recyclerviewpage.indicator.RecyclerCirclePageIndicator.java

public RecyclerCirclePageIndicator(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    if (isInEditMode())
        return;//from w  ww. java2 s .com

    //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(a.getDimension(R.styleable.CirclePageIndicator_strokeWidth, 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.android.nobug.view.viewpager.indicator.CirclePageIndicator.java

public CirclePageIndicator(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    if (isInEditMode())
        return;/*from  ww w. ja  v a  2s. com*/

    final int defaultPageColor = ContextCompat.getColor(context, android.R.color.darker_gray);
    final int defaultFillColor = ContextCompat.getColor(context, android.R.color.white);
    final int defaultOrientation = 0;
    final int defaultStrokeColor = ContextCompat.getColor(context, android.R.color.transparent);
    final float defaultStrokeWidth = 9;
    final float defaultRadius = 15;
    final boolean defaultCentered = true;
    final boolean defaultSnap = false;

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

    mCentered = a.getBoolean(R.styleable.CirclePageIndicator_indicator_centered, defaultCentered);
    mOrientation = a.getInt(R.styleable.CirclePageIndicator_android_orientation, defaultOrientation);
    mPaintPageFill.setStyle(Style.FILL);
    mPaintPageFill.setColor(a.getColor(R.styleable.CirclePageIndicator_indicator_pageColor, defaultPageColor));
    mPaintStroke.setStyle(Style.STROKE);
    mPaintStroke
            .setColor(a.getColor(R.styleable.CirclePageIndicator_indicator_strokeColor, defaultStrokeColor));
    mPaintStroke.setStrokeWidth(
            a.getDimension(R.styleable.CirclePageIndicator_indicator_strokeWidth, defaultStrokeWidth));
    mPaintFill.setStyle(Style.FILL);
    mPaintFill.setColor(a.getColor(R.styleable.CirclePageIndicator_indicator_fillColor, defaultFillColor));
    mRadius = a.getDimension(R.styleable.CirclePageIndicator_indicator_radius, defaultRadius);
    mSnap = a.getBoolean(R.styleable.CirclePageIndicator_indicator_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:ru.phplego.core.etc.viewpagerindicator.TitlePageIndicator.java

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

    //Load defaults from resources
    final Resources res = getResources();
    final int defaultFooterColor = res.getColor(Res.getId(Application.getContext().getPackageName(), "color",
            "default_title_indicator_footer_color"));
    final float defaultFooterLineHeight = res.getDimension(Res.getId(Application.getContext().getPackageName(),
            "dimen", "default_title_indicator_footer_line_height"));
    final int defaultFooterIndicatorStyle = res.getInteger(Res.getId(Application.getContext().getPackageName(),
            "integer", "default_title_indicator_footer_indicator_style"));
    final float defaultFooterIndicatorHeight = res
            .getDimension(Res.getId(Application.getContext().getPackageName(), "dimen",
                    "default_title_indicator_footer_indicator_height"));
    final float defaultFooterIndicatorUnderlinePadding = res
            .getDimension(Res.getId(Application.getContext().getPackageName(), "dimen",
                    "default_title_indicator_footer_indicator_underline_padding"));
    final float defaultFooterPadding = res.getDimension(Res.getId(Application.getContext().getPackageName(),
            "dimen", "default_title_indicator_footer_padding"));
    final int defaultSelectedColor = res.getColor(Res.getId(Application.getContext().getPackageName(), "color",
            "default_title_indicator_selected_color"));
    final boolean defaultSelectedBold = res.getBoolean(Res.getId(Application.getContext().getPackageName(),
            "bool", "default_title_indicator_selected_bold"));
    final int defaultTextColor = res.getColor(Res.getId(Application.getContext().getPackageName(), "color",
            "default_title_indicator_text_color"));
    final float defaultTextSize = res.getDimension(
            Res.getId(Application.getContext().getPackageName(), "dimen", "default_title_indicator_text_size"));
    final float defaultTitlePadding = res.getDimension(Res.getId(Application.getContext().getPackageName(),
            "dimen", "default_title_indicator_title_padding"));
    final float defaultClipPadding = res.getDimension(Res.getId(Application.getContext().getPackageName(),
            "dimen", "default_title_indicator_clip_padding"));
    final float defaultTopPadding = res.getDimension(Res.getId(Application.getContext().getPackageName(),
            "dimen", "default_title_indicator_top_padding"));

    //Retrieve styles attributes
    //TypedArray a = context.obtainStyledAttributes(attrs, Res.getId(Application.getContext().getPackageName(), "styleable", "TitlePageIndicator"), defStyle, Res.getId(Application.getContext().getPackageName(), "style", "Widget_TitlePageIndicator"));
    TypedArray a = context.obtainStyledAttributes(attrs,
            Res.getIds(Application.getContext().getPackageName(), "styleable", "TitlePageIndicator"), defStyle,
            Res.getId(Application.getContext().getPackageName(), "style", "Widget_TitlePageIndicator"));

    //Retrieve the colors to be used for this view and apply them.
    mFooterLineHeight = a.getDimension(Res.getId(Application.getContext().getPackageName(), "styleable",
            "TitlePageIndicator_footerLineHeight"), defaultFooterLineHeight);
    mFooterIndicatorStyle = IndicatorStyle
            .fromValue(a.getInteger(Res.getId(Application.getContext().getPackageName(), "styleable",
                    "TitlePageIndicator_footerIndicatorStyle"), defaultFooterIndicatorStyle));
    mFooterIndicatorHeight = a.getDimension(Res.getId(Application.getContext().getPackageName(), "styleable",
            "TitlePageIndicator_footerIndicatorHeight"), defaultFooterIndicatorHeight);
    mFooterIndicatorUnderlinePadding = a.getDimension(
            Res.getId(Application.getContext().getPackageName(), "styleable",
                    "TitlePageIndicator_footerIndicatorUnderlinePadding"),
            defaultFooterIndicatorUnderlinePadding);
    mFooterPadding = a.getDimension(Res.getId(Application.getContext().getPackageName(), "styleable",
            "TitlePageIndicator_footerPadding"), defaultFooterPadding);
    mTopPadding = a.getDimension(/*from  ww w .jav  a 2  s .  co  m*/
            Res.getId(Application.getContext().getPackageName(), "styleable", "TitlePageIndicator_topPadding"),
            defaultTopPadding);
    mTitlePadding = a.getDimension(Res.getId(Application.getContext().getPackageName(), "styleable",
            "TitlePageIndicator_titlePadding"), defaultTitlePadding);
    mClipPadding = a.getDimension(
            Res.getId(Application.getContext().getPackageName(), "styleable", "TitlePageIndicator_clipPadding"),
            defaultClipPadding);
    mColorSelected = a.getColor(Res.getId(Application.getContext().getPackageName(), "styleable",
            "TitlePageIndicator_selectedColor"), defaultSelectedColor);
    mColorText = a.getColor(
            Res.getId(Application.getContext().getPackageName(), "styleable", "TitlePageIndicator_textColor"),
            defaultTextColor);
    mBoldText = a.getBoolean(Res.getId(Application.getContext().getPackageName(), "styleable",
            "TitlePageIndicator_selectedBold"), defaultSelectedBold);

    final float textSize = a.getDimension(
            Res.getId(Application.getContext().getPackageName(), "styleable", "TitlePageIndicator_textSize"),
            defaultTextSize);
    final int footerColor = a.getColor(
            Res.getId(Application.getContext().getPackageName(), "styleable", "TitlePageIndicator_footerColor"),
            defaultFooterColor);
    mPaintText.setTextSize(textSize);
    mPaintText.setAntiAlias(true);
    mPaintFooterLine.setStyle(Paint.Style.FILL_AND_STROKE);
    mPaintFooterLine.setStrokeWidth(mFooterLineHeight);
    mPaintFooterLine.setColor(footerColor);
    mPaintFooterIndicator.setStyle(Paint.Style.FILL_AND_STROKE);
    mPaintFooterIndicator.setColor(footerColor);

    a.recycle();

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

From source file:org.hala.utilities.CirclePageIndicator.java

public CirclePageIndicator(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    if (isInEditMode())
        return;//from  w  w  w  .  j  av a2 s . com

    //Load defaults from resources
    final Resources res = getResources();
    final int defaultPageColor = ContextCompat.getColor(getContext(),
            R.color.default_circle_indicator_page_color);
    final int defaultFillColor = ContextCompat.getColor(getContext(),
            R.color.default_circle_indicator_fill_color);
    final int defaultOrientation = res.getInteger(R.integer.default_circle_indicator_orientation);
    final int defaultStrokeColor = ContextCompat.getColor(getContext(),
            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.viewpager_circleindicator_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(a.getDimension(R.styleable.CirclePageIndicator_strokeWidth, 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) {
        setBackground(background);
    }

    a.recycle();

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