private int calcItemWidth ( RecyclerView rvCategories ) { if ( itemWidth == null || itemWidth == 0 ) { for ( int i = 0 ; i < rvCategories . getChildCount ( ) ; i ++ ) { itemWidth = rvCategories . getChildAt ( i ) . getWidth ( ) ; if ( itemWidth != 0 ) { break ; } } } // in case of call before view was created if ( itemWidth == null ) { itemWidth = 0 ; } return itemWidth ; }
very big duct tape