@@ -1545,11 +1545,6 @@ private void updateTabViewLayoutParams(LinearLayout.LayoutParams lp) {
15451545 }
15461546 }
15471547
1548- @ Dimension (unit = Dimension .PX )
1549- int dpToPx (@ Dimension (unit = Dimension .DP ) int dps ) {
1550- return Math .round (getResources ().getDisplayMetrics ().density * dps );
1551- }
1552-
15531548 @ Override
15541549 protected void onDraw (Canvas canvas ) {
15551550 // Draw tab background layer for each tab item
@@ -1567,7 +1562,11 @@ protected void onDraw(Canvas canvas) {
15671562 protected void onMeasure (int widthMeasureSpec , int heightMeasureSpec ) {
15681563 // If we have a MeasureSpec which allows us to decide our height, try and use the default
15691564 // height
1570- final int idealHeight = dpToPx (getDefaultHeight ()) + getPaddingTop () + getPaddingBottom ();
1565+ final int idealHeight =
1566+ (int )
1567+ (ViewUtils .dpToPx (getContext (), getDefaultHeight ())
1568+ + getPaddingTop ()
1569+ + getPaddingBottom ());
15711570 switch (MeasureSpec .getMode (heightMeasureSpec )) {
15721571 case MeasureSpec .AT_MOST :
15731572 heightMeasureSpec =
@@ -1588,7 +1587,7 @@ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
15881587 tabMaxWidth =
15891588 requestedTabMaxWidth > 0
15901589 ? requestedTabMaxWidth
1591- : specWidth - dpToPx (TAB_MIN_WIDTH_MARGIN );
1590+ : ( int ) ( specWidth - ViewUtils . dpToPx (getContext (), TAB_MIN_WIDTH_MARGIN ) );
15921591 }
15931592
15941593 // Now super measure itself using the (possibly) modified height spec
@@ -2495,7 +2494,7 @@ private void updateTextAndIcon(
24952494 int iconMargin = 0 ;
24962495 if (hasText && iconView .getVisibility () == VISIBLE ) {
24972496 // If we're showing both text and icon, add some margin bottom to the icon
2498- iconMargin = dpToPx (DEFAULT_GAP_TEXT_ICON );
2497+ iconMargin = ( int ) ViewUtils . dpToPx (getContext (), DEFAULT_GAP_TEXT_ICON );
24992498 }
25002499 if (inlineLabel ) {
25012500 if (iconMargin != MarginLayoutParamsCompat .getMarginEnd (lp )) {
@@ -2653,7 +2652,7 @@ protected void onMeasure(final int widthMeasureSpec, final int heightMeasureSpec
26532652 return ;
26542653 }
26552654
2656- final int gutter = dpToPx (FIXED_WRAP_GUTTER_MIN );
2655+ final int gutter = ( int ) ViewUtils . dpToPx (getContext (), FIXED_WRAP_GUTTER_MIN );
26572656 boolean remeasure = false ;
26582657
26592658 if (largestTabWidth * count <= getMeasuredWidth () - gutter * 2 ) {
@@ -2815,9 +2814,10 @@ public void onAnimationEnd(Animator animator) {
28152814 */
28162815 private void calculateTabViewContentBounds (TabView tabView , RectF contentBounds ) {
28172816 int tabViewContentWidth = tabView .getContentWidth ();
2817+ int minIndicatorWidth = (int ) ViewUtils .dpToPx (getContext (), MIN_INDICATOR_WIDTH );
28182818
2819- if (tabViewContentWidth < dpToPx ( MIN_INDICATOR_WIDTH ) ) {
2820- tabViewContentWidth = dpToPx ( MIN_INDICATOR_WIDTH ) ;
2819+ if (tabViewContentWidth < minIndicatorWidth ) {
2820+ tabViewContentWidth = minIndicatorWidth ;
28212821 }
28222822
28232823 int tabViewCenter = (tabView .getLeft () + tabView .getRight ()) / 2 ;
0 commit comments