feat: 更新 Edge-to-Edge 支持,提升用户界面体验,升级相关依赖版本

This commit is contained in:
2025-12-02 18:13:11 +08:00
parent b12d772e2d
commit 626b648a22
3 changed files with 13 additions and 13 deletions

View File

@@ -47,6 +47,7 @@ dependencies {
implementation "androidx.appcompat:appcompat:$androidxAppCompatVersion" implementation "androidx.appcompat:appcompat:$androidxAppCompatVersion"
implementation "androidx.coordinatorlayout:coordinatorlayout:$androidxCoordinatorLayoutVersion" implementation "androidx.coordinatorlayout:coordinatorlayout:$androidxCoordinatorLayoutVersion"
implementation "androidx.core:core-splashscreen:$coreSplashScreenVersion" implementation "androidx.core:core-splashscreen:$coreSplashScreenVersion"
implementation "androidx.activity:activity-ktx:$androidxActivityVersion"
implementation project(':capacitor-android') implementation project(':capacitor-android')
implementation project(':capacitor-cordova-android-plugins') implementation project(':capacitor-cordova-android-plugins')
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"

View File

@@ -1,9 +1,9 @@
package com.echo.app; package com.echo.app;
import android.os.Bundle; import android.os.Bundle;
import android.view.View; import android.graphics.Color;
import androidx.core.view.WindowCompat; import androidx.activity.EdgeToEdge;
import androidx.core.view.WindowInsetsControllerCompat; import androidx.activity.SystemBarStyle;
import com.getcapacitor.BridgeActivity; import com.getcapacitor.BridgeActivity;
import com.echo.app.notification.NotificationBridgePlugin; import com.echo.app.notification.NotificationBridgePlugin;
@@ -16,13 +16,11 @@ public class MainActivity extends BridgeActivity {
registerPlugin(NotificationBridgePlugin.class); registerPlugin(NotificationBridgePlugin.class);
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
// 让内容绘制到状态栏/导航栏后面,实现沉浸式效果 // 官方 Edge-to-Edge 实现:让内容延伸到状态栏导航栏,小白条悬浮在内容之上
WindowCompat.setDecorFitsSystemWindows(getWindow(), false); EdgeToEdge.enable(
this,
// 使用浅色背景 + 深色状态栏图标,避免黑色条块感 SystemBarStyle.auto(Color.TRANSPARENT, Color.TRANSPARENT),
View decorView = getWindow().getDecorView(); SystemBarStyle.auto(Color.TRANSPARENT, Color.TRANSPARENT)
WindowInsetsControllerCompat insetsController = );
new WindowInsetsControllerCompat(getWindow(), decorView);
insetsController.setAppearanceLightStatusBars(true);
} }
} }

View File

@@ -1,8 +1,9 @@
ext { ext {
minSdkVersion = 22 minSdkVersion = 22
compileSdkVersion = 33 // Edge-to-Edge 相关依赖androidx.activity 等)要求至少 compileSdk 34
compileSdkVersion = 34
targetSdkVersion = 33 targetSdkVersion = 33
androidxActivityVersion = '1.7.0' androidxActivityVersion = '1.9.0'
androidxAppCompatVersion = '1.6.1' androidxAppCompatVersion = '1.6.1'
androidxCoordinatorLayoutVersion = '1.2.0' androidxCoordinatorLayoutVersion = '1.2.0'
androidxCoreVersion = '1.10.0' androidxCoreVersion = '1.10.0'