7

I am running android emulator 26.1.3 on my laptop with KDE Neon installed. KDE Neon is distribution based on Ubuntu 16.04 with latest KDE. The screen resolution of my laptop is 14" 3840X2160. Physical DPI == 315. In KDE 'system settings'- > 'fonts' --> 'force font DPI' set to 196.

I launched a Nexus_5X_API_26 emulator instance in ADV manager. The device profile:

hw.lcd.width = 1080
hw.lcd.height = 1920
hw.lcd.depth = 16
hw.lcd.density = 420

The emulator display like this. How to correct this?

enter image description here

trulyliu
  • 349
  • 3
  • 11
  • 1
    This is known. https://issuetracker.google.com/issues/62535436 Use a classic HiDPI workaround, such as lowering the resolution. – Tatsuyuki Ishi Aug 21 '17 at 09:29

2 Answers2

13

Short version:
1. Find your scaling factor in Displays -> Scale Display
2. Divide 1 by that scaling factor.
For example, if you have the scaling factor set to 2.0, then the result will be 0.5.
3. In your studio.sh, add somewhere after the first line, this export:
export QT_SCALE_FACTOR=[calculated scale factor reduction]

In our example, [calculated scale factor reduction] will be 0.5, so: export QT_SCALE_FACTOR=0.5.
4. Done


Additional info:
This is somewhat a KDE scaling issue.

One solution is to change the scaling back to "x1.0" but this will affect all the applications and everything will look small.

Happily, the emulator is a Qt application, thus you can change the scaling through the environment variable, without affecting the rest of the IDE or Desktop UI.

Lilian A. Moraru
  • 1,046
  • 1
  • 12
  • 20
2

For anybody running from modern Android Studio (or IDEA Ultimate), you should go to the location of your android sdk e.g. /home/<user>/Android/Sdk/emulator/ and run the following from within that directory:

# Enter your calculated scale factor e.g. 0.45 here, if your KDE scale factor is e.g. 2.2, 1/2.2 =~ 0.45
read scale_factor
mv emulator emulator.base
echo -E "#!/bin/env bash\nQT_SCALE_FACTOR=${scale_factor} $(pwd)/emulator.base $*" > $(pwd)/emulator
chmod +x $(pwd)/emulator

Credits to Lilian for their original answer

smaudet
  • 609
  • 8
  • 17
  • Only problem I have with this is it makes the settings way too small... – smaudet Oct 23 '18 at 05:21
  • just make an `alias emulator='QT_SCALE_FACTOR=0.5 /opt/android/sdk/tools/emulator'` or `alias emulator="QT_SCREEN_SCALE_FACTORS=1 /opt/android/sdk/emulator/emulator"` – sherpya Feb 04 '22 at 13:47
  • @sherpya while that's helpful I'm not sure that will work with Android Studio/IntelliJ, depending especially on the shell you are running they won't respect your aliases. – smaudet Feb 08 '23 at 13:50