Example usage for android.content.res TypedArray getDrawable

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

Introduction

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

Prototype

@Nullable
public Drawable getDrawable(@StyleableRes int index) 

Source Link

Document

Retrieve the Drawable for the attribute at index.

Usage

From source file:android.support.design.widget.CoordinatorLayout.java

public CoordinatorLayout(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);

    ThemeUtils.checkAppCompatTheme(context);

    final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.CoordinatorLayout, defStyleAttr,
            R.style.Widget_Design_CoordinatorLayout);
    final int keylineArrayRes = a.getResourceId(R.styleable.CoordinatorLayout_keylines, 0);
    if (keylineArrayRes != 0) {
        final Resources res = context.getResources();
        mKeylines = res.getIntArray(keylineArrayRes);
        final float density = res.getDisplayMetrics().density;
        final int count = mKeylines.length;
        for (int i = 0; i < count; i++) {
            mKeylines[i] *= density;// w  w  w  .ja  va 2  s.  co  m
        }
    }
    mStatusBarBackground = a.getDrawable(R.styleable.CoordinatorLayout_statusBarBackground);
    a.recycle();

    setupForInsets();
    super.setOnHierarchyChangeListener(new HierarchyChangeListener());
}

From source file:com.tr4android.support.extension.widget.FlexibleToolbarLayout.java

public FlexibleToolbarLayout(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);

    mTitleCollapsingTextHelper = new CollapsingTextHelper(this);
    mTitleCollapsingTextHelper.setTextSizeInterpolator(AnimationUtils.LINEAR_INTERPOLATOR);
    mSubtitleCollapsingTextHelper = new CollapsingTextHelper(this);
    mSubtitleCollapsingTextHelper.setTextSizeInterpolator(AnimationUtils.LINEAR_INTERPOLATOR);
    mIconCollapsingHelper = new CollapsingDrawableHelper(this);
    mIconCollapsingHelper.setIconSizeInterpolator(AnimationUtils.LINEAR_INTERPOLATOR);

    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.FlexibleToolbarLayout, defStyleAttr,
            R.style.Widget_Design_FlexibleToolbarLayout);

    int expandedVerticalGravity = a.getInt(R.styleable.FlexibleToolbarLayout_expandedGravity,
            Gravity.CENTER_VERTICAL);/*from  w w w  . j av a 2s . c o m*/

    mTitleCollapsingTextHelper.setExpandedTextGravity(GravityCompat.START | expandedVerticalGravity);
    mTitleCollapsingTextHelper.setCollapsedTextGravity(GravityCompat.START | Gravity.CENTER_VERTICAL);
    mSubtitleCollapsingTextHelper.setExpandedTextGravity(GravityCompat.START | expandedVerticalGravity);
    mSubtitleCollapsingTextHelper.setCollapsedTextGravity(GravityCompat.START | Gravity.CENTER_VERTICAL);

    mExpandedMarginLeft = mExpandedMarginTop = mExpandedMarginRight = mExpandedMarginBottom = a
            .getDimensionPixelSize(R.styleable.FlexibleToolbarLayout_expandedMargin, 0);

    final boolean isRtl = ViewCompat.getLayoutDirection(this) == ViewCompat.LAYOUT_DIRECTION_RTL;
    if (a.hasValue(R.styleable.FlexibleToolbarLayout_expandedMarginStart)) {
        final int marginStart = a.getDimensionPixelSize(R.styleable.FlexibleToolbarLayout_expandedMarginStart,
                0);
        if (isRtl) {
            mExpandedMarginRight = marginStart;
        } else {
            mExpandedMarginLeft = marginStart;
        }
    }
    if (a.hasValue(R.styleable.FlexibleToolbarLayout_expandedMarginEnd)) {
        final int marginEnd = a.getDimensionPixelSize(R.styleable.FlexibleToolbarLayout_expandedMarginEnd, 0);
        if (isRtl) {
            mExpandedMarginLeft = marginEnd;
        } else {
            mExpandedMarginRight = marginEnd;
        }
    }
    if (a.hasValue(R.styleable.FlexibleToolbarLayout_expandedMarginTop)) {
        mExpandedMarginTop = a.getDimensionPixelSize(R.styleable.FlexibleToolbarLayout_expandedMarginTop, 0);
    }
    if (a.hasValue(R.styleable.FlexibleToolbarLayout_expandedMarginBottom)) {
        mExpandedMarginBottom = a.getDimensionPixelSize(R.styleable.FlexibleToolbarLayout_expandedMarginBottom,
                0);
    }

    mCollapsingTitleEnabled = a.getBoolean(R.styleable.FlexibleToolbarLayout_titleFlexibleEnabled, true);
    setTitle(a.getText(R.styleable.FlexibleToolbarLayout_title));
    mCollapsingSubtitleEnabled = a.getBoolean(R.styleable.FlexibleToolbarLayout_subtitleFlexibleEnabled, true);
    setSubtitle(a.getText(R.styleable.FlexibleToolbarLayout_subtitle));
    mCollapsingIconEnabled = a.getBoolean(R.styleable.FlexibleToolbarLayout_iconFlexibleEnabled, true);
    setIcon(a.getDrawable(R.styleable.FlexibleToolbarLayout_icon));

    // First load the default text appearances
    mTitleCollapsingTextHelper
            .setExpandedTextAppearance(R.style.TextAppearance_Design_FlexibleToolbarLayout_ExpandedTitle);
    mTitleCollapsingTextHelper
            .setCollapsedTextAppearance(R.style.TextAppearance_Design_FlexibleToolbarLayout_CollapsedTitle);
    mSubtitleCollapsingTextHelper
            .setExpandedTextAppearance(R.style.TextAppearance_Design_FlexibleToolbarLayout_Subtitle);
    mSubtitleCollapsingTextHelper
            .setCollapsedTextAppearance(R.style.TextAppearance_Design_FlexibleToolbarLayout_Subtitle);

    // Now overlay any custom text appearances
    if (a.hasValue(R.styleable.FlexibleToolbarLayout_titleExpandedTextAppearance)) {
        mTitleCollapsingTextHelper.setExpandedTextAppearance(
                a.getResourceId(R.styleable.FlexibleToolbarLayout_titleExpandedTextAppearance, 0));
    }
    if (a.hasValue(R.styleable.FlexibleToolbarLayout_titleCollapsedTextAppearance)) {
        mTitleCollapsingTextHelper.setCollapsedTextAppearance(
                a.getResourceId(R.styleable.FlexibleToolbarLayout_titleCollapsedTextAppearance, 0));

    }
    if (a.hasValue(R.styleable.FlexibleToolbarLayout_subtitleExpandedTextAppearance)) {
        mSubtitleCollapsingTextHelper.setExpandedTextAppearance(
                a.getResourceId(R.styleable.FlexibleToolbarLayout_subtitleExpandedTextAppearance, 0));
    }
    if (a.hasValue(R.styleable.FlexibleToolbarLayout_subtitleCollapsedTextAppearance)) {
        mSubtitleCollapsingTextHelper.setCollapsedTextAppearance(
                a.getResourceId(R.styleable.FlexibleToolbarLayout_subtitleCollapsedTextAppearance, 0));

    }

    // Load the icon sizes
    mIconCollapsingHelper.setCollapsedIconSize(
            a.getDimensionPixelSize(R.styleable.FlexibleToolbarLayout_iconCollapsedSize, 0));
    mIconCollapsingHelper.setExpandedIconSize(
            a.getDimensionPixelSize(R.styleable.FlexibleToolbarLayout_iconExpandedSize, 0));

    mSpaceTitleSubtitle = a.getDimensionPixelSize(R.styleable.FlexibleToolbarLayout_spaceTitleSubtitle, 0);
    mSpaceIconTitles = a.getDimensionPixelSize(R.styleable.FlexibleToolbarLayout_spaceIconTitles, 0);

    setContentScrim(a.getDrawable(R.styleable.FlexibleToolbarLayout_contentScrimColor));
    setStatusBarScrim(a.getDrawable(R.styleable.FlexibleToolbarLayout_statusBarScrimColor));

    mToolbarId = a.getResourceId(R.styleable.FlexibleToolbarLayout_toolbarRefId, -1);

    a.recycle();

    setWillNotDraw(false);

    ViewCompat.setOnApplyWindowInsetsListener(this, new android.support.v4.view.OnApplyWindowInsetsListener() {
        @Override
        public WindowInsetsCompat onApplyWindowInsets(View v, WindowInsetsCompat insets) {
            mLastInsets = insets;
            requestLayout();
            return insets.consumeSystemWindowInsets();
        }
    });
}

From source file:android.support.designox.widget.CollapsingToolbarLayout.java

public CollapsingToolbarLayout(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);

    ThemeUtils.checkAppCompatTheme(context);

    mCollapsingTextHelper = new CollapsingTextHelper(this);
    mCollapsingTextHelper.setTextSizeInterpolator(AnimationUtils.DECELERATE_INTERPOLATOR);

    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.CollapsingToolbarLayout, defStyleAttr,
            R.style.Widget_Design_CollapsingToolbar);

    mCollapsingTextHelper.setExpandedTextGravity(a.getInt(
            R.styleable.CollapsingToolbarLayout_expandedTitleGravity, GravityCompat.START | Gravity.BOTTOM));
    mCollapsingTextHelper//from w w w  . j  a  va  2  s  .c  om
            .setCollapsedTextGravity(a.getInt(R.styleable.CollapsingToolbarLayout_collapsedTitleGravity,
                    GravityCompat.START | Gravity.CENTER_VERTICAL));

    mExpandedMarginStart = mExpandedMarginTop = mExpandedMarginEnd = mExpandedMarginBottom = a
            .getDimensionPixelSize(R.styleable.CollapsingToolbarLayout_expandedTitleMargin, 0);

    if (a.hasValue(R.styleable.CollapsingToolbarLayout_expandedTitleMarginStart)) {
        mExpandedMarginStart = a
                .getDimensionPixelSize(R.styleable.CollapsingToolbarLayout_expandedTitleMarginStart, 0);
    }
    if (a.hasValue(R.styleable.CollapsingToolbarLayout_expandedTitleMarginEnd)) {
        mExpandedMarginEnd = a.getDimensionPixelSize(R.styleable.CollapsingToolbarLayout_expandedTitleMarginEnd,
                0);
    }
    if (a.hasValue(R.styleable.CollapsingToolbarLayout_expandedTitleMarginTop)) {
        mExpandedMarginTop = a.getDimensionPixelSize(R.styleable.CollapsingToolbarLayout_expandedTitleMarginTop,
                0);
    }
    if (a.hasValue(R.styleable.CollapsingToolbarLayout_expandedTitleMarginBottom)) {
        mExpandedMarginBottom = a
                .getDimensionPixelSize(R.styleable.CollapsingToolbarLayout_expandedTitleMarginBottom, 0);
    }

    mCollapsingTitleEnabled = a.getBoolean(R.styleable.CollapsingToolbarLayout_titleEnabled, true);
    setTitle(a.getText(R.styleable.CollapsingToolbarLayout_title));

    // First load the default text appearances
    mCollapsingTextHelper.setExpandedTextAppearance(R.style.TextAppearance_Design_CollapsingToolbar_Expanded);
    mCollapsingTextHelper.setCollapsedTextAppearance(R.style.TextAppearance_AppCompat_Widget_ActionBar_Title);

    // Now overlay any custom text appearances
    if (a.hasValue(R.styleable.CollapsingToolbarLayout_expandedTitleTextAppearance)) {
        mCollapsingTextHelper.setExpandedTextAppearance(
                a.getResourceId(R.styleable.CollapsingToolbarLayout_expandedTitleTextAppearance, 0));
    }
    if (a.hasValue(R.styleable.CollapsingToolbarLayout_collapsedTitleTextAppearance)) {
        mCollapsingTextHelper.setCollapsedTextAppearance(
                a.getResourceId(R.styleable.CollapsingToolbarLayout_collapsedTitleTextAppearance, 0));
    }

    setContentScrim(a.getDrawable(R.styleable.CollapsingToolbarLayout_contentScrim));
    setStatusBarScrim(a.getDrawable(R.styleable.CollapsingToolbarLayout_statusBarScrim));

    mToolbarId = a.getResourceId(R.styleable.CollapsingToolbarLayout_toolbarId, -1);

    a.recycle();

    setWillNotDraw(false);

    ViewCompat.setOnApplyWindowInsetsListener(this,
            new android.support.v4ox.view.OnApplyWindowInsetsListener() {
                @Override
                public WindowInsetsCompat onApplyWindowInsets(View v, WindowInsetsCompat insets) {
                    return setWindowInsets(insets);
                }
            });
}

From source file:com.appunite.list.HorizontalListView.java

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

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

    CharSequence[] entries = a.getTextArray(R.styleable.ListView_android_entries);
    if (entries != null) {
        setAdapter(new ArrayAdapter<CharSequence>(context, android.R.layout.simple_list_item_1, entries));
    }/* ww w.  j  a  va  2s.  com*/

    final Drawable d = a.getDrawable(R.styleable.ListView_android_divider);
    if (d != null) {
        // If a divider is specified use its intrinsic width for divider width
        setDivider(d);
    }

    final Drawable osHeader = a.getDrawable(R.styleable.ListView_overScrollHeader);
    if (osHeader != null) {
        setOverscrollHeader(osHeader);
    }

    final Drawable osFooter = a.getDrawable(R.styleable.ListView_overScrollFooter);
    if (osFooter != null) {
        setOverscrollFooter(osFooter);
    }

    // Use the width specified, zero being the default
    final int dividerHeight = a.getDimensionPixelSize(R.styleable.ListView_android_dividerHeight, 0);
    if (dividerHeight != 0) {
        setDividerWidth(dividerHeight);
    }

    mHeaderDividersEnabled = a.getBoolean(R.styleable.ListView_headerDividersEnabled, true);
    mFooterDividersEnabled = a.getBoolean(R.styleable.ListView_footerDividersEnabled, true);

    a.recycle();
}

From source file:com.common.widget.hzlib.HorizontalListView.java

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

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

    CharSequence[] entries = a.getTextArray(R.styleable.ListView_android_entries);
    if (entries != null) {
        setAdapter(new ArrayAdapter<CharSequence>(context, android.R.layout.simple_list_item_1, entries));
    }//from w  w  w.ja v a 2 s. c  o m

    final Drawable d = a.getDrawable(R.styleable.ListView_android_divider);
    if (d != null) {
        // If a divider is specified use its intrinsic width for divider width
        setDivider(d);
    }

    final Drawable osHeader = a.getDrawable(R.styleable.ListView_overScrollHeader);
    if (osHeader != null) {
        setOverscrollHeader(osHeader);
    }

    final Drawable osFooter = a.getDrawable(R.styleable.ListView_overScrollFooter);
    if (osFooter != null) {
        setOverscrollFooter(osFooter);
    }

    // Use the width specified, zero being the default
    final int dividerHeight = a.getDimensionPixelSize(R.styleable.ListView_dividerHeight, 0);
    if (dividerHeight != 0) {
        setDividerWidth(dividerHeight);
    }

    mHeaderDividersEnabled = a.getBoolean(R.styleable.ListView_headerDividersEnabled, true);
    mFooterDividersEnabled = a.getBoolean(R.styleable.ListView_footerDividersEnabled, true);

    a.recycle();
}

From source file:com.liu.hz.view.HorizontalListView.java

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

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

    CharSequence[] entries = a.getTextArray(R.styleable.ListView_android_entries);
    if (entries != null) {
        setAdapter(new ArrayAdapter<CharSequence>(context, android.R.layout.simple_list_item_1, entries));
    }/* ww w  .ja  v a2s.  c  om*/

    final Drawable d = a.getDrawable(R.styleable.ListView_divider);
    if (d != null) {
        // If a divider is specified use its intrinsic width for divider width
        setDivider(d);
    }

    final Drawable osHeader = a.getDrawable(R.styleable.ListView_overScrollHeader);
    if (osHeader != null) {
        setOverscrollHeader(osHeader);
    }

    final Drawable osFooter = a.getDrawable(R.styleable.ListView_overScrollFooter);
    if (osFooter != null) {
        setOverscrollFooter(osFooter);
    }

    // Use the width specified, zero being the default
    final int dividerHeight = a.getDimensionPixelSize(R.styleable.ListView_dividerHeight, 0);
    if (dividerHeight != 0) {
        setDividerWidth(dividerHeight);
    }

    mHeaderDividersEnabled = a.getBoolean(R.styleable.ListView_headerDividersEnabled, true);
    mFooterDividersEnabled = a.getBoolean(R.styleable.ListView_footerDividersEnabled, true);

    a.recycle();
}

From source file:com.appunite.list.ListView.java

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

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

    CharSequence[] entries = a.getTextArray(R.styleable.ListView_android_entries);
    if (entries != null) {
        setAdapter(new ArrayAdapter<CharSequence>(context, android.R.layout.simple_list_item_1, entries));
    }/*  ww w.j av  a2  s.  c  o m*/

    final Drawable d = a.getDrawable(R.styleable.ListView_android_divider);
    if (d != null) {
        // If a divider is specified use its intrinsic width for divider width
        setDivider(d);
    }

    final Drawable osHeader = a.getDrawable(R.styleable.ListView_overScrollHeader);
    if (osHeader != null) {
        setOverscrollHeader(osHeader);
    }

    final Drawable osFooter = a.getDrawable(R.styleable.ListView_overScrollFooter);
    if (osFooter != null) {
        setOverscrollFooter(osFooter);
    }

    // Use the width specified, zero being the default
    final int dividerHeight = a.getDimensionPixelSize(R.styleable.ListView_android_dividerHeight, 0);
    if (dividerHeight != 0) {
        setDividerHeight(dividerHeight);
    }

    mHeaderDividersEnabled = a.getBoolean(R.styleable.ListView_headerDividersEnabled, true);
    mFooterDividersEnabled = a.getBoolean(R.styleable.ListView_footerDividersEnabled, true);

    a.recycle();
}

From source file:com.common.widget.hzlib.ListView.java

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

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

    CharSequence[] entries = a.getTextArray(R.styleable.ListView_android_entries);
    if (entries != null) {
        setAdapter(new ArrayAdapter<CharSequence>(context, android.R.layout.simple_list_item_1, entries));
    }/* www.  j a va 2s.  com*/

    final Drawable d = a.getDrawable(R.styleable.ListView_android_divider);
    if (d != null) {
        // If a divider is specified use its intrinsic width for divider width
        setDivider(d);
    }

    final Drawable osHeader = a.getDrawable(R.styleable.ListView_overScrollHeader);
    if (osHeader != null) {
        setOverscrollHeader(osHeader);
    }

    final Drawable osFooter = a.getDrawable(R.styleable.ListView_overScrollFooter);
    if (osFooter != null) {
        setOverscrollFooter(osFooter);
    }

    // Use the width specified, zero being the default
    final int dividerHeight = a.getDimensionPixelSize(R.styleable.ListView_dividerHeight, 0);
    if (dividerHeight != 0) {
        setDividerHeight(dividerHeight);
    }

    mHeaderDividersEnabled = a.getBoolean(R.styleable.ListView_headerDividersEnabled, true);
    mFooterDividersEnabled = a.getBoolean(R.styleable.ListView_footerDividersEnabled, true);

    a.recycle();
}

From source file:com.liu.hz.view.ListView.java

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

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

    CharSequence[] entries = a.getTextArray(R.styleable.ListView_android_entries);
    if (entries != null) {
        setAdapter(new ArrayAdapter<CharSequence>(context, android.R.layout.simple_list_item_1, entries));
    }//from   w w w  .  j a  v  a 2s.c o m

    final Drawable d = a.getDrawable(R.styleable.ListView_divider);
    if (d != null) {
        // If a divider is specified use its intrinsic width for divider width
        setDivider(d);
    }

    final Drawable osHeader = a.getDrawable(R.styleable.ListView_overScrollHeader);
    if (osHeader != null) {
        setOverscrollHeader(osHeader);
    }

    final Drawable osFooter = a.getDrawable(R.styleable.ListView_overScrollFooter);
    if (osFooter != null) {
        setOverscrollFooter(osFooter);
    }

    // Use the width specified, zero being the default
    final int dividerHeight = a.getDimensionPixelSize(R.styleable.ListView_dividerHeight, 0);
    if (dividerHeight != 0) {
        setDividerHeight(dividerHeight);
    }

    mHeaderDividersEnabled = a.getBoolean(R.styleable.ListView_headerDividersEnabled, true);
    mFooterDividersEnabled = a.getBoolean(R.styleable.ListView_footerDividersEnabled, true);

    a.recycle();
}

From source file:com.home.library.vpi.TitlePageIndicator.java

public TitlePageIndicator(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    if (isInEditMode())
        return;/*from   www  .j  av  a  2  s . c o  m*/

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

    final boolean defaultFades = res.getBoolean(R.bool.default_title_indicator_fades);
    final int defaultFadeDelay = res.getInteger(R.integer.default_title_indicator_fade_delay);
    final int defaultFadeLength = res.getInteger(R.integer.default_title_indicator_fade_length);

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

    //Retrieve the colors to be used for this view and apply them.
    mFooterLineHeight = a.getDimension(R.styleable.TitlePageIndicator_footerLineHeight,
            defaultFooterLineHeight);
    mFooterIndicatorStyle = IndicatorStyle.fromValue(
            a.getInteger(R.styleable.TitlePageIndicator_footerIndicatorStyle, defaultFooterIndicatorStyle));
    mFooterIndicatorHeight = a.getDimension(R.styleable.TitlePageIndicator_footerIndicatorHeight,
            defaultFooterIndicatorHeight);
    mFooterIndicatorUnderlinePadding = a.getDimension(
            R.styleable.TitlePageIndicator_footerIndicatorUnderlinePadding,
            defaultFooterIndicatorUnderlinePadding);
    mFooterPadding = a.getDimension(R.styleable.TitlePageIndicator_footerPadding, defaultFooterPadding);
    mLinePosition = LinePosition
            .fromValue(a.getInteger(R.styleable.TitlePageIndicator_linePosition, defaultLinePosition));
    mTopPadding = a.getDimension(R.styleable.TitlePageIndicator_topPadding, defaultTopPadding);
    mTitlePadding = a.getDimension(R.styleable.TitlePageIndicator_titlePadding, defaultTitlePadding);
    mClipPadding = a.getDimension(R.styleable.TitlePageIndicator_clipPadding, defaultClipPadding);
    mColorSelected = a.getColor(R.styleable.TitlePageIndicator_selectedColor, defaultSelectedColor);
    mColorText = a.getColor(R.styleable.TitlePageIndicator_android_textColor, defaultTextColor);
    mBoldText = a.getBoolean(R.styleable.TitlePageIndicator_selectedBold, defaultSelectedBold);
    mBackGroundColor = a.getColor(R.styleable.TitlePageIndicator_titleBackGround, defaultBackGroundColor);

    final float textSize = a.getDimension(R.styleable.TitlePageIndicator_android_textSize, defaultTextSize);
    mFooterColor = a.getColor(R.styleable.TitlePageIndicator_footerColor, defaultFooterColor);
    mPaintText.setTextSize(textSize);
    mPaintText.setAntiAlias(true);
    mPaintText.setColor(mColorText);
    mPaintText.setAlpha(0xFF);
    mPaintFooterLine.setStyle(Paint.Style.FILL_AND_STROKE);
    mPaintFooterLine.setStrokeWidth(mFooterLineHeight);
    mPaintFooterLine.setColor(mFooterColor);
    mPaintFooterIndicator.setStyle(Paint.Style.FILL_AND_STROKE);
    mPaintFooterIndicator.setColor(mFooterColor);

    mBackGroundPaint.setColor(mBackGroundColor);
    mInitBackGroundPaintAlpha = mBackGroundPaint.getAlpha();

    setFades(a.getBoolean(R.styleable.TitlePageIndicator_titleFades, defaultFades));
    setFadeDelay(a.getInteger(R.styleable.TitlePageIndicator_titleFadeDelay, defaultFadeDelay));
    setFadeLength(a.getInteger(R.styleable.TitlePageIndicator_titleFadeLength, defaultFadeLength));

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

    a.recycle();

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