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.coordinatorlayout:coordinatorlayout:$androidxCoordinatorLayoutVersion"
implementation "androidx.core:core-splashscreen:$coreSplashScreenVersion"
implementation "androidx.activity:activity-ktx:$androidxActivityVersion"
implementation project(':capacitor-android')
implementation project(':capacitor-cordova-android-plugins')
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"

View File

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

View File

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