From 455d7c5402f381a164a0d598a4cb1b6028f06a22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=8A=B2=E9=B9=8F?= Date: Tue, 14 Jan 2020 17:52:19 +0800 Subject: [PATCH] set margin via navbar instead of decor view --- .../src/main/java/pub/doric/plugin/StatusBarPlugin.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/doric-android/doric/src/main/java/pub/doric/plugin/StatusBarPlugin.java b/doric-android/doric/src/main/java/pub/doric/plugin/StatusBarPlugin.java index 7c17667a..89ae2a2e 100644 --- a/doric-android/doric/src/main/java/pub/doric/plugin/StatusBarPlugin.java +++ b/doric-android/doric/src/main/java/pub/doric/plugin/StatusBarPlugin.java @@ -2,6 +2,7 @@ package pub.doric.plugin; import android.os.Build; import android.view.View; +import android.widget.LinearLayout; import androidx.appcompat.app.AppCompatActivity; @@ -16,6 +17,7 @@ import pub.doric.async.AsyncResult; import pub.doric.extension.bridge.DoricMethod; import pub.doric.extension.bridge.DoricPlugin; import pub.doric.extension.bridge.DoricPromise; +import pub.doric.navbar.BaseDoricNavBar; import pub.doric.utils.DoricUtils; import pub.doric.utils.ThreadMode; @@ -38,13 +40,16 @@ public class StatusBarPlugin extends DoricJavaPlugin { public Object call() { AppCompatActivity activity = ((AppCompatActivity) getDoricContext().getContext()); View decorView = activity.getWindow().getDecorView(); + LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) ((BaseDoricNavBar) getDoricContext().getDoricNavBar()).getLayoutParams(); if (hidden) { - decorView.setPadding(0, DoricUtils.getStatusBarHeight(activity), 0, 0); decorView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_FULLSCREEN); + lp.topMargin = DoricUtils.getStatusBarHeight(activity); } else { - decorView.setPadding(0, 0, 0, 0); decorView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_VISIBLE); + lp.topMargin = 0; } + ((BaseDoricNavBar) getDoricContext().getDoricNavBar()).setLayoutParams(lp); + currentMode = 0; return null; }