feat: 更新 Edge-to-Edge 支持,提升用户界面体验,升级相关依赖版本
This commit is contained in:
@@ -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"
|
||||
|
||||
@@ -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)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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'
|
||||
|
||||
Reference in New Issue
Block a user