|
13 | 13 | import android.view.MenuInflater;
|
14 | 14 | import android.view.MenuItem;
|
15 | 15 | import android.view.View;
|
| 16 | +import android.view.ViewGroup; |
16 | 17 | import android.webkit.CookieManager;
|
17 | 18 | import android.webkit.JavascriptInterface;
|
18 | 19 | import android.webkit.WebResourceRequest;
|
|
25 | 26 |
|
26 | 27 | import androidx.annotation.NonNull;
|
27 | 28 | import androidx.appcompat.app.AppCompatActivity;
|
| 29 | +import androidx.core.graphics.Insets; |
| 30 | +import androidx.core.view.ViewCompat; |
| 31 | +import androidx.core.view.WindowInsetsCompat; |
28 | 32 | import androidx.loader.app.LoaderManager;
|
29 | 33 | import androidx.loader.content.Loader;
|
30 | 34 |
|
@@ -153,6 +157,17 @@ protected void onCreate(Bundle savedInstanceState) {
|
153 | 157 | setContentView(binding.getRoot());
|
154 | 158 | setSupportActionBar(binding.toolbar);
|
155 | 159 |
|
| 160 | + // Margins for the toolbar are needed, so that content of the toolbar |
| 161 | + // is not covered by a system button navigation bar when in landscape. |
| 162 | + ViewCompat.setOnApplyWindowInsetsListener(binding.toolbar, (v, windowInsets) -> { |
| 163 | + Insets insets = windowInsets.getInsets(WindowInsetsCompat.Type.systemBars()); |
| 164 | + ViewGroup.MarginLayoutParams mlp = (ViewGroup.MarginLayoutParams) v.getLayoutParams(); |
| 165 | + mlp.leftMargin = insets.left; |
| 166 | + mlp.rightMargin = insets.right; |
| 167 | + v.setLayoutParams(mlp); |
| 168 | + return windowInsets; |
| 169 | + }); |
| 170 | + |
156 | 171 | binding.webview.setBackgroundColor(Color.TRANSPARENT);
|
157 | 172 |
|
158 | 173 | if (BuildConfig.DEBUG) {
|
|
0 commit comments