Commit 7cc75426 authored by Becky Zhou's avatar Becky Zhou Committed by Commit Bot

Fix bottom margin for NTP and FeedNTP on older Android versions

On pre-N versions, the layout parameters can be ignored if we don't
declare a root the inflated view. Updating the layout parameters only
after view is attached to window.

Bug: 895229
Change-Id: I671b83bbf6e72b9cbabb84e80636d68ba45c5dad
Reviewed-on: https://chromium-review.googlesource.com/c/1282105
Commit-Queue: Becky Zhou <huayinz@chromium.org>
Reviewed-by: default avatarTheresa <twellington@chromium.org>
Cr-Commit-Position: refs/heads/master@{#600137}
parent 11e27ede
......@@ -325,7 +325,16 @@ public class NewTabPage
updateSearchProviderHasLogo();
initializeMainView(activity);
getView().addOnAttachStateChangeListener(new View.OnAttachStateChangeListener() {
@Override
public void onViewAttachedToWindow(View view) {
updateMargins(mTab.getBrowserControlsStateConstraints());
getView().removeOnAttachStateChangeListener(this);
}
@Override
public void onViewDetachedFromWindow(View view) {}
});
eventReporter.onSurfaceOpened();
......@@ -384,12 +393,7 @@ public class NewTabPage
View view = getView();
ViewGroup.MarginLayoutParams layoutParams =
((ViewGroup.MarginLayoutParams) view.getLayoutParams());
if (layoutParams == null) {
// We could be updating the margin before the root view is attached to window.
layoutParams = new ViewGroup.MarginLayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
view.setLayoutParams(layoutParams);
}
if (layoutParams == null) return;
int bottomMargin = 0;
if (FeatureUtilities.isBottomToolbarEnabled()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment