private void handleOnVisibleMenuItemsWidthChanged ( int menuItemsWidth ) { if ( menuItemsWidth == 0 ) { mClearButton . setTranslationX ( - Util . dpToPx ( 4 ) ) ; int paddingRight = Util . dpToPx ( 4 ) ; if ( mIsFocused ) { paddingRight += Util . dpToPx ( CLEAR_BTN_WIDTH_DP ) ; } else { paddingRight += Util . dpToPx ( 14 ) ; } mSearchInput . setPadding ( 0 , 0 , paddingRight , 0 ) ; } else { mClearButton . setTranslationX ( - menuItemsWidth ) ; int paddingRight = menuItemsWidth ; if ( mIsFocused ) { paddingRight += Util . dpToPx ( CLEAR_BTN_WIDTH_DP ) ; } mSearchInput . setPadding ( 0 , 0 , paddingRight , 0 ) ; } }
ensures that the end margin of the search input is according to Material specs