private RelativeLayout . LayoutParams createLayoutParams ( ) { Rect windowDimensions = new Rect ( ) ; Window window = getWindow ( ) ; assert window != null ; window . getDecorView ( ) . getWindowVisibleDisplayFrame ( windowDimensions ) ; int leftInset = isFitsSystemWindowsLeft ( ) && isFullscreen ( ) && systemWindowInsets != null ? systemWindowInsets . left : 0 ; int topInset = isFitsSystemWindowsTop ( ) && isFullscreen ( ) && systemWindowInsets != null ? systemWindowInsets . top : 0 ; int rightInset = isFitsSystemWindowsRight ( ) && isFullscreen ( ) && systemWindowInsets != null ? systemWindowInsets . right : 0 ; int bottomInset = isFitsSystemWindowsBottom ( ) && isFullscreen ( ) && systemWindowInsets != null ? systemWindowInsets . bottom : 0 ; int leftMargin = getLeftMargin ( ) - getWindowInsetLeft ( ) + leftInset ; int topMargin = getTopMargin ( ) - getWindowInsetTop ( ) + topInset ; int rightMargin = getRightMargin ( ) - getWindowInsetRight ( ) + rightInset ; int bottomMargin = getBottomMargin ( ) - getWindowInsetBottom ( ) + bottomInset ; int width = getLayoutDimension ( getWidth ( ) , leftMargin + rightMargin , windowDimensions . right ) ; int height = getLayoutDimension ( getHeight ( ) , topMargin + bottomMargin , windowDimensions . bottom ) ; RelativeLayout . LayoutParams layoutParams = new RelativeLayout . LayoutParams ( width , height ) ; layoutParams . leftMargin = leftMargin ; layoutParams . topMargin = topMargin ; layoutParams . rightMargin = rightMargin ; layoutParams . bottomMargin = bottomMargin ; if ( ( getGravity ( ) & Gravity . CENTER_HORIZONTAL ) == Gravity . CENTER_HORIZONTAL ) { layoutParams . addRule ( RelativeLayout . CENTER_HORIZONTAL , RelativeLayout . TRUE ) ; } if ( ( getGravity ( ) & Gravity . CENTER_VERTICAL ) == Gravity . CENTER_VERTICAL ) { layoutParams . addRule ( RelativeLayout . CENTER_VERTICAL , RelativeLayout . TRUE ) ; } if ( ( getGravity ( ) & Gravity . LEFT ) == Gravity . LEFT ) { layoutParams . addRule ( RelativeLayout . ALIGN_PARENT_LEFT , RelativeLayout . TRUE ) ; } if ( ( getGravity ( ) & Gravity . TOP ) == Gravity . TOP ) { layoutParams . addRule ( RelativeLayout . ALIGN_PARENT_TOP , RelativeLayout . TRUE ) ; } if ( ( getGravity ( ) & Gravity . RIGHT ) == Gravity . RIGHT ) { layoutParams . addRule ( RelativeLayout . ALIGN_PARENT_RIGHT , RelativeLayout . TRUE ) ; } if ( ( getGravity ( ) & Gravity . BOTTOM ) == Gravity . BOTTOM ) { layoutParams . addRule ( RelativeLayout . ALIGN_PARENT_BOTTOM , RelativeLayout . TRUE ) ; } return layoutParams ; }
Creates and returns the layout params which should be used by the dialog s root view .