优化
This commit is contained in:
1 parent
e5afe60a11
commit
7994ed1ed3
8 files changed
+408
-13
No files matched your search
@@ -1,9 +1,16 @@
|
||||
package edu.mingxu.jiaowu;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.graphics.Color;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.core.graphics.Insets;
|
||||
import androidx.core.view.ViewCompat;
|
||||
import androidx.core.view.WindowCompat;
|
||||
import androidx.core.view.WindowInsetsCompat;
|
||||
import androidx.core.view.WindowInsetsControllerCompat;
|
||||
|
||||
import com.getcapacitor.BridgeActivity;
|
||||
import com.getcapacitor.JSObject;
|
||||
|
||||
@@ -23,6 +30,22 @@ public class MainActivity extends BridgeActivity {
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
registerPlugin(NativeHomePlugin.class);
|
||||
super.onCreate(savedInstanceState);
|
||||
// Keep the WebView below Android system bars. The web shell also honours
|
||||
// iOS safe-area insets, so content stays clear of every supported notch.
|
||||
WindowCompat.setDecorFitsSystemWindows(getWindow(), true);
|
||||
getWindow().setStatusBarColor(Color.rgb(21, 37, 80));
|
||||
getWindow().setNavigationBarColor(Color.rgb(21, 37, 80));
|
||||
WindowInsetsControllerCompat controller =
|
||||
new WindowInsetsControllerCompat(getWindow(), getWindow().getDecorView());
|
||||
controller.setAppearanceLightStatusBars(false);
|
||||
controller.setAppearanceLightNavigationBars(false);
|
||||
ViewCompat.setOnApplyWindowInsetsListener(bridge.getWebView(), (view, insets) -> {
|
||||
Insets systemBars = insets.getInsets(
|
||||
WindowInsetsCompat.Type.systemBars() | WindowInsetsCompat.Type.displayCutout());
|
||||
view.setPadding(0, systemBars.top, 0, systemBars.bottom);
|
||||
return insets;
|
||||
});
|
||||
ViewCompat.requestApplyInsets(bridge.getWebView());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in new issue
Block a user