diff --git a/mobile/android/base/BrowserApp.java b/mobile/android/base/BrowserApp.java
index f662ea548385..1c396cd8cea4 100644
--- a/mobile/android/base/BrowserApp.java
+++ b/mobile/android/base/BrowserApp.java
@@ -110,10 +110,6 @@ abstract public class BrowserApp extends GeckoApp
// Whether the dynamic toolbar pref is enabled.
private boolean mDynamicToolbarEnabled = false;
- // The widget used to push the LayerView below the address bar when the
- // toolbar is disabled.
- private View mToolbarSpacer = null;
-
// The last recorded touch event from onInterceptTouchEvent. These are
// not updated until the movement threshold has been exceeded.
private float mLastTouchX = 0.0f;
@@ -439,8 +435,6 @@ abstract public class BrowserApp extends GeckoApp
super.onCreate(savedInstanceState);
- mToolbarSpacer = findViewById(R.id.toolbar_spacer);
-
LinearLayout actionBar = (LinearLayout) getActionBarLayout();
mMainLayout.addView(actionBar, 2);
@@ -498,7 +492,7 @@ abstract public class BrowserApp extends GeckoApp
@Override
public void run() {
if (mDynamicToolbarEnabled) {
- mToolbarSpacer.setPadding(0, 0, 0, 0);
+ setToolbarMargin(0);
} else {
// Immediately show the toolbar when disabling the dynamic
// toolbar.
@@ -601,6 +595,16 @@ abstract public class BrowserApp extends GeckoApp
mLayerView.setOnKeyListener(this);
}
+ private void setSidebarMargin(int margin) {
+ ((RelativeLayout.LayoutParams) mGeckoLayout.getLayoutParams()).leftMargin = margin;
+ mGeckoLayout.requestLayout();
+ }
+
+ private void setToolbarMargin(int margin) {
+ ((RelativeLayout.LayoutParams) mGeckoLayout.getLayoutParams()).topMargin = margin;
+ mGeckoLayout.requestLayout();
+ }
+
public void setToolbarHeight(int aHeight, int aVisibleHeight) {
if (!mDynamicToolbarEnabled || Boolean.TRUE.equals(mAboutHomeShowing)) {
// Use aVisibleHeight here so that when the dynamic toolbar is
@@ -612,11 +616,11 @@ abstract public class BrowserApp extends GeckoApp
// LayerView, which can cause visible artifacts.
mAboutHomeContent.setPadding(0, aVisibleHeight, 0, 0);
} else {
- mToolbarSpacer.setPadding(0, aVisibleHeight, 0, 0);
+ setToolbarMargin(aVisibleHeight);
}
aHeight = aVisibleHeight = 0;
} else {
- mToolbarSpacer.setPadding(0, 0, 0, 0);
+ setToolbarMargin(0);
}
// Update the Gecko-side global for fixed viewport margins.
@@ -757,9 +761,7 @@ abstract public class BrowserApp extends GeckoApp
}
mBrowserToolbar.adjustForTabsLayout(width);
-
- ((RelativeLayout.LayoutParams) mGeckoLayout.getLayoutParams()).setMargins(width, 0, 0, 0);
- mGeckoLayout.requestLayout();
+ setSidebarMargin(width);
}
if (changed) {
@@ -987,9 +989,8 @@ abstract public class BrowserApp extends GeckoApp
// Set the gecko layout for sliding.
if (!mTabsPanel.isShown()) {
- ((RelativeLayout.LayoutParams) mGeckoLayout.getLayoutParams()).setMargins(0, 0, 0, 0);
mGeckoLayout.scrollTo(mTabsPanel.getWidth() * -1, 0);
- mGeckoLayout.requestLayout();
+ setSidebarMargin(0);
}
mMainLayoutAnimator.attach(mGeckoLayout,
@@ -1036,7 +1037,7 @@ abstract public class BrowserApp extends GeckoApp
if (mTabsPanel.isShown()) {
if (hasTabsSideBar()) {
- ((RelativeLayout.LayoutParams) mGeckoLayout.getLayoutParams()).setMargins(mTabsPanel.getWidth(), 0, 0, 0);
+ setSidebarMargin(mTabsPanel.getWidth());
mGeckoLayout.scrollTo(0, 0);
}
diff --git a/mobile/android/base/resources/layout/gecko_app.xml b/mobile/android/base/resources/layout/gecko_app.xml
index f6a46bed55e0..b95db5bd7e13 100644
--- a/mobile/android/base/resources/layout/gecko_app.xml
+++ b/mobile/android/base/resources/layout/gecko_app.xml
@@ -19,10 +19,6 @@
-
-