From 04ee72a33d620c1bf0fc5a5091577e5b0dfebc55 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E8=B0=A6=E5=90=9B?=
<73606411+setube@users.noreply.github.com>
Date: Thu, 25 Dec 2025 20:00:13 +0800
Subject: [PATCH] =?UTF-8?q?feat:=20=E5=AE=89=E5=8D=93=E7=AB=AF=E6=94=AF?=
=?UTF-8?q?=E6=8C=81=E6=B2=89=E6=B5=B8=E5=BC=8F=E8=BE=B9=E5=88=B0=E8=BE=B9?=
=?UTF-8?q?=E6=98=BE=E7=A4=BA?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
MainActivity启用Edge-to-Edge,状态栏与导航栏设为透明并强制深色图标,提升沉浸体验。styles.xml同步调整相关颜色为透明。CSS中优化html平滑过渡样式,提升界面切换流畅度。
---
.../java/games/wenzi/ogame/MainActivity.java | 21 +++++++++++++++----
android/app/src/main/res/values/styles.xml | 6 ++++--
src/style.css | 10 ++++-----
3 files changed, 26 insertions(+), 11 deletions(-)
diff --git a/android/app/src/main/java/games/wenzi/ogame/MainActivity.java b/android/app/src/main/java/games/wenzi/ogame/MainActivity.java
index 8eeb0c5..9489197 100644
--- a/android/app/src/main/java/games/wenzi/ogame/MainActivity.java
+++ b/android/app/src/main/java/games/wenzi/ogame/MainActivity.java
@@ -1,8 +1,10 @@
package games.wenzi.ogame;
+import android.graphics.Color;
import android.os.Bundle;
import android.view.Window;
-import androidx.core.content.ContextCompat;
+import androidx.core.view.WindowCompat;
+import androidx.core.view.WindowInsetsControllerCompat;
import com.getcapacitor.BridgeActivity;
public class MainActivity extends BridgeActivity {
@@ -10,9 +12,20 @@ public class MainActivity extends BridgeActivity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- // 设置状态栏颜色,防止 Capacitor 强制透明
Window window = getWindow();
- window.setStatusBarColor(ContextCompat.getColor(this, R.color.status_bar_color));
- window.setNavigationBarColor(ContextCompat.getColor(this, R.color.status_bar_color));
+
+ // 启用边到边显示(Edge-to-Edge)
+ WindowCompat.setDecorFitsSystemWindows(window, false);
+
+ // 设置透明状态栏和导航栏
+ window.setStatusBarColor(Color.TRANSPARENT);
+ window.setNavigationBarColor(Color.TRANSPARENT);
+
+ // 设置状态栏图标为浅色(因为背景是深色)
+ WindowInsetsControllerCompat controller = WindowCompat.getInsetsController(window, window.getDecorView());
+ if (controller != null) {
+ controller.setAppearanceLightStatusBars(false);
+ controller.setAppearanceLightNavigationBars(false);
+ }
}
}
diff --git a/android/app/src/main/res/values/styles.xml b/android/app/src/main/res/values/styles.xml
index 6a6c20a..ad35f23 100644
--- a/android/app/src/main/res/values/styles.xml
+++ b/android/app/src/main/res/values/styles.xml
@@ -13,8 +13,10 @@
- false
- true
- @null
- - #1a1a2e
- - #1a1a2e
+ - @android:color/transparent
+ - @android:color/transparent
+ - false
+ - false
diff --git a/src/style.css b/src/style.css
index d4c10e8..5bed97c 100644
--- a/src/style.css
+++ b/src/style.css
@@ -120,6 +120,11 @@
@apply border-border outline-ring/50;
}
+ html {
+ /* 平滑过渡 */
+ transition: background-color 0.3s ease, color 0.3s ease;
+ }
+
body {
@apply bg-background text-foreground;
font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
@@ -128,11 +133,6 @@
-moz-osx-font-smoothing: grayscale;
}
- /* 平滑过渡 */
- html {
- transition: background-color 0.3s ease, color 0.3s ease;
- }
-
/* 滚动条样式 */
::-webkit-scrollbar {
width: 8px;