Skip to content
This repository has been archived by the owner on Oct 18, 2023. It is now read-only.

Commit

Permalink
优化
Browse files Browse the repository at this point in the history
  • Loading branch information
821938089 committed Jul 11, 2023
1 parent 03d1447 commit b172f9a
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions app/src/main/java/io/legado/app/utils/ActivityExtensions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,17 @@ val WindowManager.windowSize: DisplayMetrics
val windowMetrics: WindowMetrics = currentWindowMetrics
val insets = windowMetrics.windowInsets
.getInsetsIgnoringVisibility(WindowInsets.Type.systemBars())
displayMetrics.widthPixels = windowMetrics.bounds.width() - insets.left - insets.right
displayMetrics.heightPixels = windowMetrics.bounds.height() - insets.top - insets.bottom
val windowWidth = windowMetrics.bounds.width()
val windowHeight = windowMetrics.bounds.height()
var insetsWidth = insets.left + insets.right
var insetsHeight = insets.top + insets.bottom
if (windowWidth > windowHeight) {
val tmp = insetsWidth
insetsWidth = insetsHeight
insetsHeight = tmp
}
displayMetrics.widthPixels = windowWidth - insetsWidth
displayMetrics.heightPixels = windowHeight - insetsHeight
} else {
@Suppress("DEPRECATION")
defaultDisplay.getMetrics(displayMetrics)
Expand Down

0 comments on commit b172f9a

Please sign in to comment.