Example usage for android.content.res TypedArray getColor

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

Introduction

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

Prototype

@ColorInt
public int getColor(@StyleableRes int index, @ColorInt int defValue) 

Source Link

Document

Retrieve the color value for the attribute at index.

Usage

From source file:cc.wudoumi.framework.views.PagerSlidingTabStrip.java

public PagerSlidingTabStrip(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    tabBackgroundResId = R.drawable.background_tab;
    setFillViewport(true);/*from   www.  j  av a 2 s.  c o  m*/
    setWillNotDraw(false);

    tabsContainer = new LinearLayout(context);
    tabsContainer.setOrientation(LinearLayout.HORIZONTAL);
    tabsContainer.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
    addView(tabsContainer);

    DisplayMetrics dm = getResources().getDisplayMetrics();

    scrollOffset = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, scrollOffset, dm);
    indicatorHeight = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, indicatorHeight, dm);
    underlineHeight = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, underlineHeight, dm);
    dividerPadding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dividerPadding, dm);
    tabPadding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, tabPadding, dm);
    dividerWidth = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dividerWidth, dm);
    tabTextSize = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, tabTextSize, dm);

    // get system attrs (android:textSize and android:textColor)

    TypedArray a = context.obtainStyledAttributes(attrs, ATTRS);

    tabTextSize = a.getDimensionPixelSize(0, tabTextSize);
    //tabTextColor = a.getColor(1, tabTextColor);
    textColor = a.getColorStateList(1);
    if (textColor == null) {
        textColor = ColorStateList.valueOf(tabTextColor);
    }
    a.recycle();

    // get custom attrs

    a = context.obtainStyledAttributes(attrs, R.styleable.PagerSlidingTabStrip);

    indicatorColor = a.getColor(R.styleable.PagerSlidingTabStrip_pstsIndicatorColor, indicatorColor);
    underlineColor = a.getColor(R.styleable.PagerSlidingTabStrip_pstsUnderlineColor, underlineColor);
    dividerColor = a.getColor(R.styleable.PagerSlidingTabStrip_pstsDividerColor, dividerColor);
    indicatorHeight = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsIndicatorHeight,
            indicatorHeight);
    underlineHeight = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsUnderlineHeight,
            underlineHeight);
    dividerPadding = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsDividerPadding,
            dividerPadding);
    tabPadding = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsTabPaddingLeftRight, tabPadding);
    tabBackgroundResId = a.getResourceId(R.styleable.PagerSlidingTabStrip_pstsTabBackground,
            tabBackgroundResId);
    shouldExpand = a.getBoolean(R.styleable.PagerSlidingTabStrip_pstsShouldExpand, shouldExpand);
    scrollOffset = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsScrollOffset, scrollOffset);
    textAllCaps = a.getBoolean(R.styleable.PagerSlidingTabStrip_pstsTextAllCaps, textAllCaps);

    selecttabTextSize = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsSelectTextSize,
            tabTextSize);
    a.recycle();

    rectPaint = new Paint();
    rectPaint.setAntiAlias(true);
    rectPaint.setStyle(Style.FILL);

    dividerPaint = new Paint();
    dividerPaint.setAntiAlias(true);
    dividerPaint.setStrokeWidth(dividerWidth);

    defaultTabLayoutParams = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
            LayoutParams.MATCH_PARENT);
    expandedTabLayoutParams = new LinearLayout.LayoutParams(0, LayoutParams.MATCH_PARENT, 1.0f);

    if (locale == null) {
        locale = getResources().getConfiguration().locale;
    }

    tabTextSizeChange = tabTextSize != selecttabTextSize;
}

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

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

    ThemeUtils.checkAppCompatTheme(context);

    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.FloatingActionButton, defStyleAttr,
            R.style.Widget_Design_FloatingActionButton);
    mBackgroundTint = a.getColorStateList(R.styleable.FloatingActionButton_backgroundTint);
    mBackgroundTintMode = ViewUtils/*from   w w  w  . ja  v  a2 s  . c o  m*/
            .parseTintMode(a.getInt(R.styleable.FloatingActionButton_backgroundTintMode, -1), null);
    mRippleColor = a.getColor(R.styleable.FloatingActionButton_rippleColor, 0);
    mSize = a.getInt(R.styleable.FloatingActionButton_fabSize, SIZE_AUTO);
    mBorderWidth = a.getDimensionPixelSize(R.styleable.FloatingActionButton_borderWidth, 0);
    final float elevation = a.getDimension(R.styleable.FloatingActionButton_elevation, 0f);
    final float pressedTranslationZ = a.getDimension(R.styleable.FloatingActionButton_pressedTranslationZ, 0f);
    mCompatPadding = a.getBoolean(R.styleable.FloatingActionButton_useCompatPadding, false);
    a.recycle();

    mImageHelper = new AppCompatImageHelper(this);
    mImageHelper.loadFromAttributes(attrs, defStyleAttr);

    mMaxImageSize = (int) getResources().getDimension(R.dimen.design_fab_image_size);

    getImpl().setBackgroundDrawable(mBackgroundTint, mBackgroundTintMode, mRippleColor, mBorderWidth);
    getImpl().setElevation(elevation);
    getImpl().setPressedTranslationZ(pressedTranslationZ);
}

From source file:com.bvhloc.numpicker.widget.NumberPicker.java

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

    mStart = DEFAULT_START;// w  w  w.  java 2s .  co  m
    mEnd = DEFAULT_END;
    mCurrent = mStart;

    boolean vertical = true;
    int displayedValues = 0;

    if (attrs != null && !isInEditMode()) {
        // this crashes in edit mode (?!)
        TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.NumberPicker);

        mStart = a.getInt(R.styleable.NumberPicker_rangeStart, DEFAULT_START);
        mEnd = a.getInt(R.styleable.NumberPicker_rangeEnd, DEFAULT_END);
        mSpeed = a.getInt(R.styleable.NumberPicker_speed, (int) mSpeed);
        mSpeedUp = mSpeed;
        mCurrent = a.getInt(R.styleable.NumberPicker_current, mCurrent);

        mNumColor = a.getColor(R.styleable.NumberPicker_numColor,
                ContextCompat.getColor(context, android.R.color.primary_text_light));
        mNumBackground = a.getDrawable(R.styleable.NumberPicker_numBackground);
        mNumSize = a.getDimension(R.styleable.NumberPicker_numSize, mNumSize);
        mNumHorizontalPadding = (int) a.getDimension(R.styleable.NumberPicker_numHorizontalPadding, mNumSize);
        mNumHorizontalPadding = (int) a.getDimension(R.styleable.NumberPicker_numVeticalPadding, mNumSize);
        mIncrementDrawable = a.getDrawable(R.styleable.NumberPicker_incrementDrawable);
        mDecrementDrawable = a.getDrawable(R.styleable.NumberPicker_decrementDrawable);
        mKeyboardInput = a.getBoolean(R.styleable.NumberPicker_keyboardInput, mKeyboardInput);

        String orientation = a.getString(R.styleable.NumberPicker_android_orientation);
        displayedValues = a.getResourceId(R.styleable.NumberPicker_displayedValues, 0);

        if (orientation != null) {
            vertical = !"0".equals(orientation);
        }

        a.recycle();
    } else if (attrs != null && isInEditMode()) {
        // fix orientation attribute for editor
        String orientation = attrs.getAttributeValue("http://schemas.android.com/apk/res/android",
                "orientation");

        if (orientation != null) {
            vertical = !"horizontal".equals(orientation);
        }
    }
    // set a wrong orientation so our own orientation method will perform changes
    super.setOrientation(!vertical ? VERTICAL : HORIZONTAL);
    setOrientation(vertical ? VERTICAL : HORIZONTAL);

    mChangeHandler = new Handler();
    InputFilter inputFilter = new NumberPickerInputFilter();
    mNumberInputFilter = new NumberRangeKeyListener();
    mIncrementButton = (NumberPickerButton) findViewById(R.id.increment);
    mIncrementButton.setOnClickListener(this);
    mIncrementButton.setOnLongClickListener(this);
    mIncrementButton.setNumberPicker(this);
    mDecrementButton = (NumberPickerButton) findViewById(R.id.decrement);
    mDecrementButton.setOnClickListener(this);
    mDecrementButton.setOnLongClickListener(this);
    mDecrementButton.setNumberPicker(this);

    mIncrementButton.setBackground(null);
    mDecrementButton.setBackground(null);
    mIncrementButton.setScaleType(ImageView.ScaleType.FIT_CENTER);
    mDecrementButton.setScaleType(ImageView.ScaleType.FIT_CENTER);

    if (mIncrementDrawable != null) {
        mIncrementButton.setImageDrawable(mIncrementDrawable);
    }
    if (mDecrementDrawable != null) {
        mDecrementButton.setImageDrawable(mDecrementDrawable);
    }

    mText = (EditText) findViewById(R.id.timepicker_input);
    mText.setOnFocusChangeListener(this);
    mText.setFilters(new InputFilter[] { inputFilter });
    mText.setRawInputType(InputType.TYPE_CLASS_NUMBER);
    LayoutParams params = (LayoutParams) mText.getLayoutParams();
    params.weight = 1;
    mText.setLayoutParams(params);

    mText.setPadding(mNumHorizontalPadding, mNumVerticalPadding, mNumHorizontalPadding, mNumVerticalPadding);
    mText.setTextSize(mNumSize);
    if (mNumBackground != null) {
        mText.setBackground(mNumBackground);
    } else {
        mText.setBackground(ContextCompat.getDrawable(context, android.R.drawable.edit_text));
    }
    if (!mKeyboardInput) {
        mText.setEnabled(false);
    }
    mText.setTextColor(mNumColor);

    if (!isEnabled()) {
        setEnabled(false);
    }

    if (displayedValues != 0) {
        setDisplayedRange(mStart, displayedValues);
    } else {
        setRange(mStart, mEnd);
    }
}

From source file:com.doodle.android.chips.ChipsView.java

private void initAttr(Context context, AttributeSet attrs) {
    TypedArray a = context.getTheme().obtainStyledAttributes(attrs, R.styleable.ChipsView, 0, 0);
    try {//from ww w  . j  a  v  a2 s  .c o m
        mMaxHeight = a.getDimensionPixelSize(R.styleable.ChipsView_cv_max_height, DEFAULT_MAX_HEIGHT);
        mVerticalSpacing = a.getDimensionPixelSize(R.styleable.ChipsView_cv_vertical_spacing,
                (int) (DEFAULT_VERTICAL_SPACING * mDensity));
        mChipsColor = a.getColor(R.styleable.ChipsView_cv_color,
                ContextCompat.getColor(context, R.color.base30));
        mChipsColorClicked = a.getColor(R.styleable.ChipsView_cv_color_clicked,
                ContextCompat.getColor(context, R.color.colorPrimaryDark));
        mChipsColorErrorClicked = a.getColor(R.styleable.ChipsView_cv_color_error_clicked,
                ContextCompat.getColor(context, R.color.color_error));
        mChipsBgColor = a.getColor(R.styleable.ChipsView_cv_bg_color,
                ContextCompat.getColor(context, R.color.base10));
        mChipsBgColorClicked = a.getColor(R.styleable.ChipsView_cv_bg_color_clicked,
                ContextCompat.getColor(context, R.color.blue));
        mChipsBgColorIndelible = a.getColor(R.styleable.ChipsView_cv_bg_color_indelible, mChipsBgColor);
        mChipsBgColorErrorClicked = a.getColor(R.styleable.ChipsView_cv_bg_color_clicked,
                ContextCompat.getColor(context, R.color.color_error));
        mChipsTextColor = a.getColor(R.styleable.ChipsView_cv_text_color, Color.BLACK);
        mChipsTextColorClicked = a.getColor(R.styleable.ChipsView_cv_text_color_clicked, Color.WHITE);
        mChipsTextColorErrorClicked = a.getColor(R.styleable.ChipsView_cv_text_color_clicked, Color.WHITE);
        mChipsTextColorIndelible = a.getColor(R.styleable.ChipsView_cv_text_color_indelible, mChipsTextColor);
        mChipsPlaceholderResId = a.getResourceId(R.styleable.ChipsView_cv_icon_placeholder,
                R.drawable.ic_person_24dp);
        mChipsPlaceholderTint = a.getColor(R.styleable.ChipsView_cv_icon_placeholder_tint, 0);
        mChipsDeleteResId = a.getResourceId(R.styleable.ChipsView_cv_icon_delete, R.drawable.ic_close_24dp);
        mChipsHintText = a.getString(R.styleable.ChipsView_cv_text_hint);
        mChipsMargin = a.getDimensionPixelSize(R.styleable.ChipsView_cv_chips_margin, 0);
    } finally {
        a.recycle();
    }
}

From source file:com.devbrackets.android.recyclerext.widget.FastScroll.java

/**
 * Retrieves the xml attributes associated with the drag handle.
 * This includes the drawable and tint color
 *
 * @param typedArray The array of attributes to use
 */// w w  w.  j  a  va 2s . c  o m
protected void retrieveHandleAttributes(@NonNull TypedArray typedArray) {
    Drawable backgroundDrawable = getDrawable(typedArray, R.styleable.FastScroll_re_handle_background);
    int backgroundColor = getColor(R.color.recyclerext_fast_scroll_handle_color_default);
    backgroundColor = typedArray.getColor(R.styleable.FastScroll_re_handle_color, backgroundColor);

    if (backgroundDrawable == null) {
        backgroundDrawable = tint(getDrawable(R.drawable.recyclerext_fast_scroll_handle), backgroundColor);
    }

    handle.setBackground(backgroundDrawable);
}

From source file:com.android.inputmethod.keyboard.emoji.EmojiPalettesView.java

public EmojiPalettesView(final Context context, final AttributeSet attrs, final int defStyle) {
    super(context, attrs, defStyle);
    final TypedArray keyboardViewAttr = context.obtainStyledAttributes(attrs, R.styleable.KeyboardView,
            defStyle, R.style.KeyboardView);
    final int keyBackgroundId = keyboardViewAttr.getResourceId(R.styleable.KeyboardView_keyBackground, 0);
    mFunctionalKeyBackgroundId = keyboardViewAttr
            .getResourceId(R.styleable.KeyboardView_functionalKeyBackground, keyBackgroundId);
    mSpacebarBackgroundId = keyboardViewAttr.getResourceId(R.styleable.KeyboardView_spacebarBackground,
            keyBackgroundId);//  www .j ava  2 s .c om
    keyboardViewAttr.recycle();
    final KeyboardLayoutSet.Builder builder = new KeyboardLayoutSet.Builder(context, null /* editorInfo */);
    final Resources res = context.getResources();
    mEmojiLayoutParams = new EmojiLayoutParams(res);
    builder.setSubtype(RichInputMethodSubtype.getEmojiSubtype());
    builder.setKeyboardGeometry(ResourceUtils.getDefaultKeyboardWidth(res),
            mEmojiLayoutParams.mEmojiKeyboardHeight);
    final KeyboardLayoutSet layoutSet = builder.build();
    final TypedArray emojiPalettesViewAttr = context.obtainStyledAttributes(attrs,
            R.styleable.EmojiPalettesView, defStyle, R.style.EmojiPalettesView);
    mEmojiCategory = new EmojiCategory(PreferenceManager.getDefaultSharedPreferences(context), res, layoutSet,
            emojiPalettesViewAttr);
    mCategoryIndicatorEnabled = emojiPalettesViewAttr
            .getBoolean(R.styleable.EmojiPalettesView_categoryIndicatorEnabled, false);
    mCategoryIndicatorDrawableResId = emojiPalettesViewAttr
            .getResourceId(R.styleable.EmojiPalettesView_categoryIndicatorDrawable, 0);
    mCategoryIndicatorBackgroundResId = emojiPalettesViewAttr
            .getResourceId(R.styleable.EmojiPalettesView_categoryIndicatorBackground, 0);
    mCategoryPageIndicatorColor = emojiPalettesViewAttr
            .getColor(R.styleable.EmojiPalettesView_categoryPageIndicatorColor, 0);
    mCategoryPageIndicatorBackground = emojiPalettesViewAttr
            .getColor(R.styleable.EmojiPalettesView_categoryPageIndicatorBackground, 0);
    emojiPalettesViewAttr.recycle();
    mDeleteKeyOnTouchListener = new DeleteKeyOnTouchListener();
}

From source file:com.commonsware.cwac.crossport.design.widget.FloatingActionButton.java

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

    // ThemeUtils.checkAppCompatTheme(context);

    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.FloatingActionButton, defStyleAttr,
            R.style.Widget_Design_FloatingActionButton);
    mBackgroundTint = a.getColorStateList(R.styleable.FloatingActionButton_android_backgroundTint);
    mBackgroundTintMode = ViewUtils/*w w w .  j ava2 s  .co  m*/
            .parseTintMode(a.getInt(R.styleable.FloatingActionButton_android_backgroundTintMode, -1), null);
    mRippleColor = a.getColor(R.styleable.FloatingActionButton_rippleColor, 0);
    mSize = a.getInt(R.styleable.FloatingActionButton_fabSize, SIZE_AUTO);
    mCustomSize = a.getDimensionPixelSize(R.styleable.FloatingActionButton_fabCustomSize, 0);
    mBorderWidth = a.getDimensionPixelSize(R.styleable.FloatingActionButton_borderWidth, 0);
    final float elevation = a.getDimension(R.styleable.FloatingActionButton_android_elevation, 0f);
    final float pressedTranslationZ = a.getDimension(R.styleable.FloatingActionButton_pressedTranslationZ, 0f);
    mCompatPadding = a.getBoolean(R.styleable.FloatingActionButton_useCompatPadding, false);
    a.recycle();

    /*
        mImageHelper = new AppCompatImageHelper(this);
        mImageHelper.loadFromAttributes(attrs, defStyleAttr);
    */

    mMaxImageSize = (int) getResources().getDimension(R.dimen.design_fab_image_size);

    getImpl().setBackgroundDrawable(mBackgroundTint, mBackgroundTintMode, mRippleColor, mBorderWidth);
    getImpl().setElevation(elevation);
    getImpl().setPressedTranslationZ(pressedTranslationZ);
}

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

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

    TypedArray a = context.getTheme().obtainStyledAttributes(attrs, R.styleable.InteractiveLineGraphView,
            defStyle, defStyle);/*from  ww  w  . ja v a  2s.co m*/

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

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

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

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

    initPaints();

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

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

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

From source file:com.android.launcher3.Utilities.java

public static int getColorAccent(Context context) {
    TypedArray ta = context.obtainStyledAttributes(new int[] { android.R.attr.colorAccent });
    int colorAccent = ta.getColor(0, 0);
    ta.recycle();/*from  ww  w .j  av  a  2s  .  c o  m*/
    return colorAccent;
}

From source file:com.eccyan.widget.SpinningTabStrip.java

public SpinningTabStrip(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    setFillViewport(true);//from  w ww.  j a  v a  2s  .  c o m
    setWillNotDraw(false);
    tabsContainer = new LinearLayout(context);
    tabsContainer.setOrientation(LinearLayout.HORIZONTAL);
    tabsContainer.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
    addView(tabsContainer);

    flingVelocity = new Scroller(getContext());
    flinger = new Flinger();
    gestureDetector = new GestureDetector(getContext(), new GestureDetector.SimpleOnGestureListener() {
        @Override
        public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {

            flingVelocity.forceFinished(true);
            flingVelocity.fling(getScrollX(), getScrollY(), -(int) velocityX, -(int) velocityY,
                    Integer.MIN_VALUE, Integer.MAX_VALUE, 0, getHeight());

            scrollStopped.set(false);
            Log.d(TAG, "scroll fling started");

            return true;
        }

        @Override
        public boolean onDown(MotionEvent e) {
            if (!flingVelocity.isFinished()) {
                flingVelocity.forceFinished(true);
            }

            if (!flinger.isFinished()) {
                flinger.forceFinished(true);
            }

            return super.onDown(e);
        }
    });

    DisplayMetrics dm = getResources().getDisplayMetrics();
    scrollOffset = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, scrollOffset, dm);
    indicatorHeight = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, indicatorHeight, dm);
    underlineHeight = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, underlineHeight, dm);
    dividerPadding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dividerPadding, dm);
    tabPadding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, tabPadding, dm);
    dividerWidth = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dividerWidth, dm);
    tabTextSize = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, tabTextSize, dm);

    // get system attrs (android:textSize and android:textColor)
    TypedArray a = context.obtainStyledAttributes(attrs, ATTRS);
    tabTextSize = a.getDimensionPixelSize(TEXT_SIZE_INDEX, tabTextSize);
    ColorStateList colorStateList = a.getColorStateList(TEXT_COLOR_INDEX);
    int textPrimaryColor = a.getColor(TEXT_COLOR_PRIMARY, android.R.color.white);
    if (colorStateList != null) {
        tabTextColor = colorStateList;
    } else {
        tabTextColor = getColorStateList(textPrimaryColor);
    }

    underlineColor = textPrimaryColor;
    dividerColor = textPrimaryColor;
    indicatorColor = textPrimaryColor;

    // get custom attrs
    a = context.obtainStyledAttributes(attrs, R.styleable.SpinningTabStrip);
    indicatorColor = a.getColor(R.styleable.SpinningTabStrip_pstsIndicatorColor, indicatorColor);
    underlineColor = a.getColor(R.styleable.SpinningTabStrip_pstsUnderlineColor, underlineColor);
    dividerColor = a.getColor(R.styleable.SpinningTabStrip_pstsDividerColor, dividerColor);
    dividerWidth = a.getDimensionPixelSize(R.styleable.SpinningTabStrip_pstsDividerWidth, dividerWidth);
    indicatorHeight = a.getDimensionPixelSize(R.styleable.SpinningTabStrip_pstsIndicatorHeight,
            indicatorHeight);
    underlineHeight = a.getDimensionPixelSize(R.styleable.SpinningTabStrip_pstsUnderlineHeight,
            underlineHeight);
    dividerPadding = a.getDimensionPixelSize(R.styleable.SpinningTabStrip_pstsDividerPadding, dividerPadding);
    tabPadding = a.getDimensionPixelSize(R.styleable.SpinningTabStrip_pstsTabPaddingLeftRight, tabPadding);
    tabBackgroundResId = a.getResourceId(R.styleable.SpinningTabStrip_pstsTabBackground, tabBackgroundResId);
    shouldExpand = a.getBoolean(R.styleable.SpinningTabStrip_pstsShouldExpand, shouldExpand);
    scrollOffset = a.getDimensionPixelSize(R.styleable.SpinningTabStrip_pstsScrollOffset, scrollOffset);
    textAllCaps = a.getBoolean(R.styleable.SpinningTabStrip_pstsTextAllCaps, textAllCaps);
    tabTypefaceStyle = a.getInt(R.styleable.SpinningTabStrip_pstsTextStyle, Typeface.BOLD);
    tabTypefaceSelectedStyle = a.getInt(R.styleable.SpinningTabStrip_pstsTextSelectedStyle, Typeface.BOLD);
    tabTextAlpha = a.getFloat(R.styleable.SpinningTabStrip_pstsTextAlpha, HALF_TRANSP);
    tabTextSelectedAlpha = a.getFloat(R.styleable.SpinningTabStrip_pstsTextSelectedAlpha, OPAQUE);

    a.recycle();

    setMarginBottomTabContainer();

    rectPaint = new Paint();
    rectPaint.setAntiAlias(true);
    rectPaint.setStyle(Style.FILL);

    dividerPaint = new Paint();
    dividerPaint.setAntiAlias(true);
    dividerPaint.setStrokeWidth(dividerWidth);

    defaultTabLayoutParams = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
            LayoutParams.MATCH_PARENT);
    expandedTabLayoutParams = new LinearLayout.LayoutParams(0, LayoutParams.MATCH_PARENT, 1.0f);

    if (locale == null) {
        locale = getResources().getConfiguration().locale;
    }

}