static int [ ] getMeasurementsForShiftingMode ( Context context , int screenWidth , int noOfTabs , boolean scrollable ) { int [ ] result = new int [ 2 ] ; int minWidth = ( int ) context . getResources ( ) . getDimension ( R . dimen . shifting_min_width_inactive ) ; int maxWidth = ( int ) context . getResources ( ) . getDimension ( R . dimen . shifting_max_width_inactive ) ; double minPossibleWidth = minWidth * ( noOfTabs + 0.5 ) ; double maxPossibleWidth = maxWidth * ( noOfTabs + 0.75 ) ; int itemWidth ; int itemActiveWidth ; if ( screenWidth < minPossibleWidth ) { if ( scrollable ) { itemWidth = minWidth ; itemActiveWidth = ( int ) ( minWidth * 1.5 ) ; } else { itemWidth = ( int ) ( screenWidth / ( noOfTabs + 0.5 ) ) ; itemActiveWidth = ( int ) ( itemWidth * 1.5 ) ; } } else if ( screenWidth > maxPossibleWidth ) { itemWidth = maxWidth ; itemActiveWidth = ( int ) ( itemWidth * 1.75 ) ; } else { double minPossibleWidth1 = minWidth * ( noOfTabs + 0.625 ) ; double minPossibleWidth2 = minWidth * ( noOfTabs + 0.75 ) ; itemWidth = ( int ) ( screenWidth / ( noOfTabs + 0.5 ) ) ; itemActiveWidth = ( int ) ( itemWidth * 1.5 ) ; if ( screenWidth > minPossibleWidth1 ) { itemWidth = ( int ) ( screenWidth / ( noOfTabs + 0.625 ) ) ; itemActiveWidth = ( int ) ( itemWidth * 1.625 ) ; if ( screenWidth > minPossibleWidth2 ) { itemWidth = ( int ) ( screenWidth / ( noOfTabs + 0.75 ) ) ; itemActiveWidth = ( int ) ( itemWidth * 1.75 ) ; } } } result [ 0 ] = itemWidth ; result [ 1 ] = itemActiveWidth ; return result ; }
Used to get Measurements for MODE_SHIFTING