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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]