Skip to content

Commit

Permalink
android: Fix display scaling issue on some devices
Browse files Browse the repository at this point in the history
  • Loading branch information
YuKongA committed Nov 2, 2024
1 parent 9178b6a commit 2c91d2b
Showing 1 changed file with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@ class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

// Fix display scaling issue on some devices, such as Xiaomi 15 / Xiaomi 15 Pro
val metrics = resources.displayMetrics
val density = metrics.density
val targetDensity = Math.round(density)
metrics.density = targetDensity.toFloat()
metrics.densityDpi = targetDensity * 160
resources.displayMetrics.setTo(metrics)

AndroidAppContext.init(this)
enableEdgeToEdge()
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
Expand Down

0 comments on commit 2c91d2b

Please sign in to comment.