private void setViewLayoutParams ( ) { // Some extra margin to center other buttons in the center of the main button final int EXTRA_MARGIN = ( int ) ( sWidth * ( mainButtonSize - otherButtonSize ) / 2 ) ; Log . d ( TAG , "otherButton: " + otherButtonSize ) ; Log . d ( TAG , "mainButton: " + mainButtonSize ) ; RelativeLayout . LayoutParams rParams = ( LayoutParams ) mCloseBtn . getLayoutParams ( ) ; rParams . width = ( int ) ( sWidth * otherButtonSize ) ; rParams . height = ( int ) ( sWidth * otherButtonSize ) ; rParams . setMargins ( 0 , 0 , 0 , ( int ) ( sHeight * bottomPadding + EXTRA_MARGIN ) ) ; rParams = ( LayoutParams ) mMidContainer . getLayoutParams ( ) ; rParams . setMargins ( 0 , 0 , 0 , ( int ) ( sHeight * bottomPadding + EXTRA_MARGIN ) ) ; rParams = ( LayoutParams ) mRightContainer . getLayoutParams ( ) ; rParams . setMargins ( 0 , 0 , 0 , ( int ) ( sHeight * bottomPadding + EXTRA_MARGIN ) ) ; rParams = ( LayoutParams ) mLeftContainer . getLayoutParams ( ) ; rParams . setMargins ( 0 , 0 , 0 , ( int ) ( sHeight * bottomPadding + EXTRA_MARGIN ) ) ; LinearLayout . LayoutParams params = ( LinearLayout . LayoutParams ) mMidBtn . getLayoutParams ( ) ; params . width = ( int ) ( sWidth * otherButtonSize ) ; params . height = ( int ) ( sWidth * otherButtonSize ) ; params = ( LinearLayout . LayoutParams ) mRightBtn . getLayoutParams ( ) ; params . width = ( int ) ( sWidth * otherButtonSize ) ; params . height = ( int ) ( sWidth * otherButtonSize ) ; params = ( LinearLayout . LayoutParams ) mLeftBtn . getLayoutParams ( ) ; params . width = ( int ) ( sWidth * otherButtonSize ) ; params . height = ( int ) ( sWidth * otherButtonSize ) ; }
Initialized the layout of menu buttons . Sets button sizes and distances between them by a % of screen width or height accordingly . Some extra padding between buttons is added by default to avoid intersections .