List of usage examples for android.content.res TypedArray getDimension
public float getDimension(@StyleableRes int index, float defValue)
From source file:me.futuretechnology.util.ui.TitlePageIndicator.java
public TitlePageIndicator(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); if (isInEditMode()) { return;// w w w.j a va 2s . c o m } // TODO clean this up // Load defaults from resources Resources res = getResources(); int defaultFooterColor = res.getColor(R.color.default_title_indicator_footer_color); float defaultFooterLineHeight = res.getDimension(R.dimen.default_title_indicator_footer_line_height); float defaultFooterIndicatorHeight = res .getDimension(R.dimen.default_title_indicator_footer_indicator_height); float defaultFooterIndicatorUnderlinePadding = res .getDimension(R.dimen.default_title_indicator_footer_indicator_underline_padding); float defaultFooterPadding = res.getDimension(R.dimen.default_title_indicator_footer_padding); int defaultSelectedColor = res.getColor(R.color.default_title_indicator_selected_color); boolean defaultSelectedBold = res.getBoolean(R.bool.default_title_indicator_selected_bold); int defaultTextColor = res.getColor(R.color.default_title_indicator_text_color); float defaultTextSize = res.getDimension(R.dimen.default_title_indicator_text_size); float defaultTitlePadding = res.getDimension(R.dimen.default_title_indicator_title_padding); float defaultClipPadding = res.getDimension(R.dimen.default_title_indicator_clip_padding); float defaultTopPadding = res.getDimension(R.dimen.default_title_indicator_top_padding); // 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); mFooterIndicatorHeight = a.getDimension(R.styleable.TitlePageIndicator_footerIndicatorHeight, defaultFooterIndicatorHeight); mFooterIndicatorUnderlinePadding = a.getDimension( R.styleable.TitlePageIndicator_footerIndicatorUnderlinePadding, defaultFooterIndicatorUnderlinePadding); mFooterPadding = a.getDimension(R.styleable.TitlePageIndicator_footerPadding, defaultFooterPadding); 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_textColor, defaultTextColor); mBoldText = a.getBoolean(R.styleable.TitlePageIndicator_selectedBold, defaultSelectedBold); float textSize = a.getDimension(R.styleable.TitlePageIndicator_textSize, defaultTextSize); int footerColor = a.getColor(R.styleable.TitlePageIndicator_footerColor, defaultFooterColor); mPaintText.setTextSize(textSize); mPaintText.setAntiAlias(true); mPaintText.setDither(true); mPaintText.setTypeface(Typeface.create("sans-serif-condensed", Typeface.NORMAL)); mPaintFooterLine.setStyle(Paint.Style.FILL_AND_STROKE); // noinspection SuspiciousNameCombination mPaintFooterLine.setStrokeWidth(mFooterLineHeight); mPaintFooterLine.setColor(footerColor); mPaintFooterIndicator.setDither(true); // http://code.google.com/p/android/issues/detail?id=24873 // bug when enabling hardware acceleration // workaround #1: disable hw acceleration => the drawing will be rough // setLayerType(View.LAYER_TYPE_SOFTWARE, mPaintFooterIndicator); // workaround #2: avoid using 0 as stroke width => the drawing will be smooth as butter mPaintFooterIndicator.setStrokeWidth(1); mPaintFooterIndicator.setStyle(Paint.Style.FILL_AND_STROKE); mPaintFooterIndicator.setColor(footerColor); a.recycle(); ViewConfiguration configuration = ViewConfiguration.get(context); mTouchSlop = ViewConfigurationCompat.getScaledPagingTouchSlop(configuration); }
From source file:com.adkdevelopment.e_contact.utils.UnderlinePageIndicator.java
@TargetApi(Build.VERSION_CODES.M) public UnderlinePageIndicator(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); if (isInEditMode()) return;// w ww. j a v a2 s. c om final Resources res = getResources(); //Load defaults from resources final boolean defaultFades = res.getBoolean(R.bool.default_underline_indicator_fades); final int defaultFadeDelay = res.getInteger(R.integer.default_underline_indicator_fade_delay); final int defaultFadeLength = res.getInteger(R.integer.default_underline_indicator_fade_length); int defaultSelectedColor; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { defaultSelectedColor = res.getColor(R.color.white, context.getTheme()); } else { //noinspection deprecation defaultSelectedColor = res.getColor(R.color.white); } //Retrieve styles attributes TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.UnderlinePageIndicator, defStyle, 0); setFades(a.getBoolean(R.styleable.UnderlinePageIndicator_fades, defaultFades)); setSelectedColor(a.getColor(R.styleable.UnderlinePageIndicator_selectedColor, defaultSelectedColor)); setFadeDelay(a.getInteger(R.styleable.UnderlinePageIndicator_fadeDelay, defaultFadeDelay)); setFadeLength(a.getInteger(R.styleable.UnderlinePageIndicator_fadeLength, defaultFadeLength)); mCornerRadius = a.getDimension(R.styleable.UnderlinePageIndicator_vpi_corner_radius, 0); Drawable background = a.getDrawable(R.styleable.UnderlinePageIndicator_android_background); if (background != null) { setBackground(background); } a.recycle(); final ViewConfiguration configuration = ViewConfiguration.get(context); mTouchSlop = ViewConfigurationCompat.getScaledPagingTouchSlop(configuration); }
From source file:com.fanfou.app.opensource.ui.viewpager.TitlePageIndicator.java
public TitlePageIndicator(final Context context, final AttributeSet attrs, final int defStyle) { super(context, attrs, defStyle); // 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 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); // Retrieve styles attributes final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.TitlePageIndicator, defStyle, R.style.Widget_TitlePageIndicator); // Retrieve the colors to be used for this view and apply them. this.mFooterLineHeight = a.getDimension(R.styleable.TitlePageIndicator_footerLineHeight, defaultFooterLineHeight);//from w w w . j av a2 s . com this.mFooterIndicatorStyle = IndicatorStyle.fromValue( a.getInteger(R.styleable.TitlePageIndicator_footerIndicatorStyle, defaultFooterIndicatorStyle)); this.mFooterIndicatorHeight = a.getDimension(R.styleable.TitlePageIndicator_footerIndicatorHeight, defaultFooterIndicatorHeight); this.mFooterIndicatorUnderlinePadding = a.getDimension( R.styleable.TitlePageIndicator_footerIndicatorUnderlinePadding, defaultFooterIndicatorUnderlinePadding); this.mFooterPadding = a.getDimension(R.styleable.TitlePageIndicator_footerPadding, defaultFooterPadding); this.mTitlePadding = a.getDimension(R.styleable.TitlePageIndicator_titlePadding, defaultTitlePadding); this.mClipPadding = a.getDimension(R.styleable.TitlePageIndicator_clipPadding, defaultClipPadding); this.mColorSelected = a.getColor(R.styleable.TitlePageIndicator_selectedColor, defaultSelectedColor); this.mColorText = a.getColor(R.styleable.TitlePageIndicator_textColor, defaultTextColor); this.mBoldText = a.getBoolean(R.styleable.TitlePageIndicator_selectedBold, defaultSelectedBold); final float textSize = a.getDimension(R.styleable.TitlePageIndicator_textSize, defaultTextSize); final int footerColor = a.getColor(R.styleable.TitlePageIndicator_footerColor, defaultFooterColor); this.mPaintText = new Paint(); this.mPaintText.setTextSize(textSize); this.mPaintText.setAntiAlias(true); this.mPaintFooterLine = new Paint(); this.mPaintFooterLine.setStyle(Paint.Style.FILL_AND_STROKE); this.mPaintFooterLine.setStrokeWidth(this.mFooterLineHeight); this.mPaintFooterLine.setColor(footerColor); this.mPaintFooterIndicator = new Paint(); this.mPaintFooterIndicator.setStyle(Paint.Style.FILL_AND_STROKE); this.mPaintFooterIndicator.setColor(footerColor); a.recycle(); this.mPath = new Path(); }
From source file:net.qiujuer.genius.ui.widget.GeniusBalloonMarker.java
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1) public GeniusBalloonMarker(Context context, AttributeSet attrs, int defStyleAttr, String maxValue) { super(context, attrs, defStyleAttr); DisplayMetrics displayMetrics = context.getResources().getDisplayMetrics(); int padding = (int) (PADDING_DP * displayMetrics.density) * 2; mNumber = new TextView(context); //Add some padding to this textView so the bubble has some space to breath mNumber.setPadding(padding, 0, padding, 0); mNumber.setGravity(Gravity.CENTER);/* ww w .j a v a 2 s . c om*/ mNumber.setText(maxValue); mNumber.setMaxLines(1); mNumber.setSingleLine(true); GeniusCompat.setTextDirection(mNumber, TEXT_DIRECTION_LOCALE); mNumber.setVisibility(View.INVISIBLE); //add some padding for the elevation shadow not to be clipped //I'm sure there are better ways of doing this... setPadding(padding, padding, padding, padding); resetSizes(maxValue); mSeparation = (int) (SEPARATION_DP * displayMetrics.density); mBalloonMarkerDrawable = new BalloonMarkerDrawable(ColorStateList.valueOf(Color.TRANSPARENT), 0); mBalloonMarkerDrawable.setCallback(this); mBalloonMarkerDrawable.setMarkerListener(this); mBalloonMarkerDrawable.setExternalOffset(padding); GeniusCompat.setOutlineProvider(this, mBalloonMarkerDrawable); if (attrs != null) { TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.GeniusBalloonMarker, R.attr.GeniusBalloonMarkerStyle, R.style.DefaultBalloonMarkerStyle); int textAppearanceId = a.getResourceId(R.styleable.GeniusBalloonMarker_g_markerTextAppearance, R.style.DefaultBalloonMarkerTextAppearanceStyle); setTextAppearance(textAppearanceId); ColorStateList color = a.getColorStateList(R.styleable.GeniusBalloonMarker_g_markerBackgroundColor); setBackgroundColor(color); //Elevation for android 5+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { float elevation = a.getDimension(R.styleable.GeniusBalloonMarker_g_markerElevation, ELEVATION_DP * displayMetrics.density); ViewCompat.setElevation(this, elevation); } a.recycle(); } }
From source file:com.dirkgassen.wator.ui.view.RangeSlider.java
/** * Read out the attributes from the given attribute set and initialize whatever they represent. * * @param attributeArray typed array containing the attribute values from the XML file *//*from w w w . j a v a 2s . c om*/ private void setupAttributes(TypedArray attributeArray) { minValue = attributeArray.getInt(R.styleable.RangeSlider_minValue, 0); maxValue = attributeArray.getInt(R.styleable.RangeSlider_maxValue, 100); thumbPadding = attributeArray.getDimension(R.styleable.RangeSlider_thumbPadding, 6 /* dp */ * displayDensity); thumbFormat = attributeArray.getString(R.styleable.RangeSlider_thumbFormat); if (thumbFormat == null) { thumbFormat = "%d"; } String valueSetString = attributeArray.getString(R.styleable.RangeSlider_valueSet); if (valueSetString == null) { value = attributeArray.getInt(R.styleable.RangeSlider_android_value, minValue); } else { String[] values = valueSetString.split(","); valueSet = new int[values.length]; for (int no = 0; no < values.length; no++) { valueSet[no] = Integer.valueOf(values[no]); } Arrays.sort(valueSet); value = attributeArray.getInt(R.styleable.RangeSlider_android_value, valueSet[0]); } thumbTextPaint.setTextSize(attributeArray.getDimension(R.styleable.RangeSlider_android_textSize, 12)); thumbTextPaint.setColor(attributeArray.getColor(R.styleable.RangeSlider_android_textColor, ContextCompat.getColor(getContext(), android.R.color.white))); thumbBackgroundPaint.setStyle(Paint.Style.FILL); thumbBackgroundPaint.setColor(attributeArray.getColor(R.styleable.RangeSlider_android_color, ContextCompat.getColor(getContext(), android.R.color.black))); sliderPaint.setStrokeWidth(attributeArray.getDimension(R.styleable.RangeSlider_sliderThickness, 2)); sliderPaint.setStrokeCap(Paint.Cap.ROUND); sliderPaint.setColor(thumbBackgroundPaint.getColor()); }
From source file:com.lovejjfg.demo.TouchCircleView.java
public TouchCircleView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); float density = context.getResources().getDisplayMetrics().density; TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.HeaderProgress, defStyleAttr, 0); mBorderWidth = a.getDimension(R.styleable.HeaderProgress_circleBorderWidth, 2 * density); outCirRadius = (int) a.getDimension(R.styleable.HeaderProgress_outRadius, 18 * density); innerCirRadius = (int) a.getDimension(R.styleable.HeaderProgress_innerRadius, 10 * density); secondRadius = (int) (outCirRadius * 1.5f); // innerCirRadius = (int) (outCirRadius * 0.6f); a.recycle();/*from ww w . j a va 2 s . co m*/ initView(); }
From source file:com.journeyapps.barcodescanner.WXViewfinderView.java
public WXViewfinderView(Context context, AttributeSet attrs) { super(context, attrs); // Initialize these once for performance rather than calling them every time in onDraw(). maskPaint = new Paint(Paint.ANTI_ALIAS_FLAG); borderPaint = new Paint(Paint.ANTI_ALIAS_FLAG); cornerPaint = new Paint(Paint.ANTI_ALIAS_FLAG); textPaint = new Paint(Paint.ANTI_ALIAS_FLAG); Resources resources = getResources(); // Get setted attributes on view TypedArray attributes = getContext().obtainStyledAttributes(attrs, R.styleable.zxing_WXViewfinderView); this.maskColor = attributes.getColor(R.styleable.zxing_WXViewfinderView_zxing_mask_color, Color.parseColor("#8c000000")); this.laserColor = attributes.getColor(R.styleable.zxing_WXViewfinderView_zxing_laser_color, Color.parseColor("#d90000")); this.cornerColor = attributes.getColor(R.styleable.zxing_WXViewfinderView_zxing_corner_color, Color.parseColor("#d90000")); this.borderColor = attributes.getColor(R.styleable.zxing_WXViewfinderView_zxing_border_color, Color.parseColor("#dfdfdf")); this.borderWidth = attributes.getDimension(R.styleable.zxing_WXViewfinderView_zxing_border_width, 1); this.cornerWidth = attributes.getDimension(R.styleable.zxing_WXViewfinderView_zxing_corner_width, 3); this.cornerLength = attributes.getDimension(R.styleable.zxing_WXViewfinderView_zxing_corner_length, 12); this.statusText = attributes.getString(R.styleable.zxing_WXViewfinderView_zxing_status_text); if (statusText == null) { statusText = "?????"; }/* w ww.j a v a 2 s .com*/ this.statusTextColor = attributes.getColor(R.styleable.zxing_WXViewfinderView_zxing_status_color, Color.parseColor("#b6b0b0")); this.statusTextPadding = attributes.getDimension(R.styleable.zxing_WXViewfinderView_zxing_status_padding, 32); this.statusTextSize = attributes.getDimensionPixelSize(R.styleable.zxing_WXViewfinderView_zxing_status_size, 24); maskPaint.setStyle(Paint.Style.FILL); maskPaint.setColor(maskColor); borderPaint.setStyle(Paint.Style.STROKE); borderPaint.setStrokeWidth(borderWidth); borderPaint.setColor(borderColor); cornerPaint.setStrokeWidth(cornerWidth); cornerPaint.setColor(cornerColor); cornerPaint.setStyle(Paint.Style.STROKE); textPaint.setTextSize(statusTextSize); textPaint.setColor(statusTextColor); attributes.recycle(); }
From source file:com.landenlabs.all_devtool.NumBaseFragment.java
protected void addNum(String name, int attrId, String numType) { int[] attrs = { attrId }; TypedArray typedArray = m_context.getTheme().obtainStyledAttributes(attrs); String str = ""; if (typedArray != null) { TypedValue typedValue = new TypedValue(); try {/*w w w .j a va2s .c o m*/ str = "???"; int cnt = typedArray.getIndexCount(); for (int idx = 0; idx != cnt; idx++) { int attrIdx = typedArray.getIndex(idx); str = typedArray.getString(attrIdx); int refId = typedArray.getResourceId(attrIdx, -1); if (refId != -1 && refId != attrId) { addNum(name, refId, numType); } if (TextUtils.isEmpty(str)) { float val = typedArray.getDimension(0, -1); if (val != -1) str = String.valueOf(val); } if (!TextUtils.isEmpty(str)) m_list.add(new NumInfo(name, str, numType)); } if (cnt == 0) { if (m_context.getTheme().resolveAttribute(attrId, typedValue, true)) { str = (String) typedValue.coerceToString(); m_list.add(new NumInfo(name, str, numType)); } } } catch (Exception ex) { m_log.e("peekValue", ex); } typedArray.recycle(); } }
From source file:cn.colink.commumication.swipelistview.SwipeListView.java
/** * Init ListView//www . j a va 2 s. co m * * @param attrs AttributeSet */ private void init(AttributeSet attrs) { int swipeMode = SWIPE_MODE_BOTH; boolean swipeOpenOnLongPress = true; boolean swipeCloseAllItemsWhenMoveList = true; long swipeAnimationTime = 0; float swipeOffsetLeft = 0; float swipeOffsetRight = 0; int swipeActionLeft = SWIPE_ACTION_REVEAL; int swipeActionRight = SWIPE_ACTION_REVEAL; if (attrs != null) { TypedArray styled = getContext().obtainStyledAttributes(attrs, R.styleable.SwipeListView); swipeMode = styled.getInt(R.styleable.SwipeListView_swipeMode, SWIPE_MODE_BOTH); swipeActionLeft = styled.getInt(R.styleable.SwipeListView_swipeActionLeft, SWIPE_ACTION_REVEAL); swipeActionRight = styled.getInt(R.styleable.SwipeListView_swipeActionRight, SWIPE_ACTION_REVEAL); swipeOffsetLeft = styled.getDimension(R.styleable.SwipeListView_swipeOffsetLeft, 0); swipeOffsetRight = styled.getDimension(R.styleable.SwipeListView_swipeOffsetRight, 0); swipeOpenOnLongPress = styled.getBoolean(R.styleable.SwipeListView_swipeOpenOnLongPress, true); swipeAnimationTime = styled.getInteger(R.styleable.SwipeListView_swipeAnimationTime, 0); swipeCloseAllItemsWhenMoveList = styled .getBoolean(R.styleable.SwipeListView_swipeCloseAllItemsWhenMoveList, true); swipeFrontView = styled.getResourceId(R.styleable.SwipeListView_swipeFrontView, 0); swipeBackView = styled.getResourceId(R.styleable.SwipeListView_swipeBackView, 0); } if (swipeFrontView == 0 || swipeBackView == 0) { swipeFrontView = getContext().getResources().getIdentifier(SWIPE_DEFAULT_FRONT_VIEW, "id", getContext().getPackageName()); swipeBackView = getContext().getResources().getIdentifier(SWIPE_DEFAULT_BACK_VIEW, "id", getContext().getPackageName()); if (swipeFrontView == 0 || swipeBackView == 0) { throw new RuntimeException(String.format( "You forgot the attributes swipeFrontView or swipeBackView. You can add this attributes or use '%s' and '%s' identifiers", SWIPE_DEFAULT_FRONT_VIEW, SWIPE_DEFAULT_BACK_VIEW)); } } final ViewConfiguration configuration = ViewConfiguration.get(getContext()); touchSlop = ViewConfigurationCompat.getScaledPagingTouchSlop(configuration); touchListener = new SwipeListViewTouchListener(this, swipeFrontView, swipeBackView); if (swipeAnimationTime > 0) { touchListener.setAnimationTime(swipeAnimationTime); } touchListener.setRightOffset(swipeOffsetRight); touchListener.setLeftOffset(swipeOffsetLeft); touchListener.setSwipeActionLeft(swipeActionLeft); touchListener.setSwipeActionRight(swipeActionRight); touchListener.setSwipeMode(swipeMode); touchListener.setSwipeClosesAllItemsWhenListMoves(swipeCloseAllItemsWhenMoveList); touchListener.setSwipeOpenOnLongPress(swipeOpenOnLongPress); setOnTouchListener(touchListener); setOnScrollListener(touchListener.makeScrollListener()); }
From source file:com.jinzht.pro.smarttablayout.SmartTabLayout.java
public SmartTabLayout(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); // Disable the Scroll Bar setHorizontalScrollBarEnabled(false); // Make sure that the Tab Strips fills this View setFillViewport(true);//from w w w .ja v a2 s . c o m final DisplayMetrics dm = getResources().getDisplayMetrics(); final float density = dm.density; int tabBackgroundResId = NO_ID; boolean textAllCaps = TAB_VIEW_TEXT_ALL_CAPS; ColorStateList textColors; float textSize = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP, dm); int textHorizontalPadding = (int) (TAB_VIEW_PADDING_DIPS * density); int textMinWidth = (int) (TAB_VIEW_TEXT_MIN_WIDTH * density); boolean distributeEvenly = DEFAULT_DISTRIBUTE_EVENLY; int customTabLayoutId = NO_ID; int customTabTextViewId = NO_ID; TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.stl_SmartTabLayout, defStyle, 0); tabBackgroundResId = a.getResourceId(R.styleable.stl_SmartTabLayout_stl_defaultTabBackground, tabBackgroundResId); textAllCaps = a.getBoolean(R.styleable.stl_SmartTabLayout_stl_defaultTabTextAllCaps, textAllCaps); textColors = a.getColorStateList(R.styleable.stl_SmartTabLayout_stl_defaultTabTextColor); textSize = a.getDimension(R.styleable.stl_SmartTabLayout_stl_defaultTabTextSize, textSize); textHorizontalPadding = a.getDimensionPixelSize( R.styleable.stl_SmartTabLayout_stl_defaultTabTextHorizontalPadding, textHorizontalPadding); textMinWidth = a.getDimensionPixelSize(R.styleable.stl_SmartTabLayout_stl_defaultTabTextMinWidth, textMinWidth); customTabLayoutId = a.getResourceId(R.styleable.stl_SmartTabLayout_stl_customTabTextLayoutId, customTabLayoutId); customTabTextViewId = a.getResourceId(R.styleable.stl_SmartTabLayout_stl_customTabTextViewId, customTabTextViewId); distributeEvenly = a.getBoolean(R.styleable.stl_SmartTabLayout_stl_distributeEvenly, distributeEvenly); a.recycle(); this.titleOffset = (int) (TITLE_OFFSET_DIPS * density); this.tabViewBackgroundResId = tabBackgroundResId; this.tabViewTextAllCaps = textAllCaps; this.tabViewTextColors = (textColors != null) ? textColors : ColorStateList.valueOf(TAB_VIEW_TEXT_COLOR); this.tabViewTextSize = textSize; this.tabViewTextHorizontalPadding = textHorizontalPadding; this.tabViewTextMinWidth = textMinWidth; this.distributeEvenly = distributeEvenly; if (customTabLayoutId != NO_ID) { setCustomTabView(customTabLayoutId, customTabTextViewId); } this.tabStrip = new SmartTabStrip(context, attrs); if (distributeEvenly && tabStrip.isIndicatorAlwaysInCenter()) { throw new UnsupportedOperationException( "'distributeEvenly' and 'indicatorAlwaysInCenter' both use does not support"); } addView(tabStrip, LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); }