You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cordova.apache.org by "tomitank (via GitHub)" <gi...@apache.org> on 2026/04/08 23:26:24 UTC

[I] Replace Margin with Padding in edge-to-edge code [cordova-android]

tomitank opened a new issue, #1915:
URL: https://github.com/apache/cordova-android/issues/1915

   # Bug Report
   I don't understand why use margin instead of padding. 
   
   ## Problem
   With margin has bug eg in Admob Banner on Android 7.
   
   ## Padding code:
   `rootLayout.setPadding(left, top, right, bottom);`
   
   full:
   `    protected void createViews() {
           WindowCompat.setDecorFitsSystemWindows(getWindow(), false);
   
           // Root FrameLayout
           FrameLayout rootLayout = new FrameLayout(this);
           rootLayout.setLayoutParams(new FrameLayout.LayoutParams(
                   ViewGroup.LayoutParams.MATCH_PARENT,
                   ViewGroup.LayoutParams.MATCH_PARENT
           ));
   
           // WebView
           View webView = appView.getView();
           webView.setLayoutParams(new FrameLayout.LayoutParams(
                   ViewGroup.LayoutParams.MATCH_PARENT,
                   ViewGroup.LayoutParams.MATCH_PARENT
           ));
   
           // Create StatusBar view that will overlay the top inset
           View statusBarView = new View(this);
           statusBarView.setTag("statusBarView");
   
           // Handle Window Insets
           ViewCompat.setOnApplyWindowInsetsListener(rootLayout, (v, insets) -> {
               Insets bars = insets.getInsets(
                       WindowInsetsCompat.Type.systemBars() | WindowInsetsCompat.Type.displayCutout()
               );
   
               boolean isStatusBarVisible = statusBarView.getVisibility() != View.GONE;
               int top = isStatusBarVisible && !canEdgeToEdge && !isFullScreen ? bars.top : 0;
               int bottom = !canEdgeToEdge && !isFullScreen ? bars.bottom : 0;
               int left = !canEdgeToEdge && !isFullScreen ? bars.left : 0;
               int right = !canEdgeToEdge && !isFullScreen ? bars.right : 0;
   
               FrameLayout.LayoutParams webViewParams = (FrameLayout.LayoutParams) webView.getLayoutParams();
               //webViewParams.setMargins(left, top, right, bottom);
               rootLayout.setPadding(left, top, right, bottom);
               webView.setLayoutParams(webViewParams);
   
               FrameLayout.LayoutParams statusBarParams = new FrameLayout.LayoutParams(
                       ViewGroup.LayoutParams.MATCH_PARENT,
                       top,
                       Gravity.TOP
               );
               statusBarView.setLayoutParams(statusBarParams);
   
               return insets;
           });
   
           rootLayout.addView(webView);
           rootLayout.addView(statusBarView);
   
           setContentView(rootLayout);
           rootLayout.post(() -> ViewCompat.requestApplyInsets(rootLayout));
           webView.requestFocusFromTouch();
       }`
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


Re: [I] Replace Margin with Padding in edge-to-edge code [cordova-android]

Posted by "tomitank (via GitHub)" <gi...@apache.org>.
tomitank closed issue #1915: Replace Margin with Padding in edge-to-edge code
URL: https://github.com/apache/cordova-android/issues/1915


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


Re: [I] Replace Margin with Padding in edge-to-edge code [cordova-android]

Posted by "dpogue (via GitHub)" <gi...@apache.org>.
dpogue commented on issue #1915:
URL: https://github.com/apache/cordova-android/issues/1915#issuecomment-4210610911

   One reason is that Android WebViews do not respect `padding`


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org