Skip to content

Commit 96d9a6f

Browse files
committed
Fix #12
1 parent bd2fd41 commit 96d9a6f

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

android/src/main/kotlin/qiuxiang/android_window/AndroidWindow.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,12 @@ class AndroidWindow(
116116
windowManager.removeView(rootView)
117117
}
118118

119+
fun updateLayout() {
120+
@Suppress("Deprecation")
121+
windowManager.defaultDisplay.getMetrics(metrics)
122+
setPosition(layoutParams.x, layoutParams.y)
123+
}
124+
119125
fun setLayout(width: Int, height: Int) {
120126
layoutParams.width = width
121127
layoutParams.height = height

android/src/main/kotlin/qiuxiang/android_window/WindowService.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import android.app.Notification
44
import android.app.NotificationChannel
55
import android.app.NotificationManager
66
import android.content.Intent
7+
import android.content.res.Configuration
78
import android.os.Build
89
import android.os.IBinder
910
import io.flutter.embedding.engine.FlutterEngine
@@ -19,6 +20,11 @@ class WindowService : android.app.Service() {
1920
return null
2021
}
2122

23+
override fun onConfigurationChanged(newConfig: Configuration) {
24+
super.onConfigurationChanged(newConfig)
25+
androidWindow.updateLayout()
26+
}
27+
2228
override fun onStartCommand(intent: Intent, flags: Int, startId: Int): Int {
2329
if (!running) {
2430
engine = FlutterEngine(application)

0 commit comments

Comments
 (0)