From 0d9fb4abd49f04e9b554ab6071b3218f104ef85d Mon Sep 17 00:00:00 2001 From: Andreas Schildbach Date: Thu, 4 Feb 2021 20:13:35 +0100 Subject: [PATCH] MyActionBar: Use window inset listener for top inset, rather than the status bar height dimension. --- oeffi/src/de/schildbach/oeffi/MyActionBar.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/oeffi/src/de/schildbach/oeffi/MyActionBar.java b/oeffi/src/de/schildbach/oeffi/MyActionBar.java index 80704b5..bf2600e 100644 --- a/oeffi/src/de/schildbach/oeffi/MyActionBar.java +++ b/oeffi/src/de/schildbach/oeffi/MyActionBar.java @@ -67,6 +67,11 @@ public class MyActionBar extends LinearLayout { this.context = context; this.res = getResources(); inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); + + setOnApplyWindowInsetsListener((v, insets) -> { + v.setPadding(0, insets.getSystemWindowInsetTop(), 0, 0); + return insets; + }); } @Override @@ -81,11 +86,6 @@ public class MyActionBar extends LinearLayout { progressView = findViewById(R.id.action_bar_progress); progressButton = findViewById(R.id.action_bar_progress_button); progressImage = findViewById(R.id.action_bar_progress_image); - - // Make sure action bar isn't stuck under a transparent status bar. - final int statusHeight = res - .getDimensionPixelSize(res.getIdentifier("status_bar_height", "dimen", "android")); - setPadding(getPaddingLeft(), getPaddingTop() + statusHeight, getPaddingRight(), getPaddingBottom()); } public void setDrawer(final OnClickListener onClickListener) {