Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android emulator on hidpi displayer?

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

like image 463
trulyliu Avatar asked Aug 10 '17 04:08

trulyliu


People also ask

How do I make Android emulator full screen?

Alt+Enter is the keyboard shortcut to toggle full screen mode in the emulator, just do it again to exit full screen.


2 Answers

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.

like image 138
Lilian A. Moraru Avatar answered Sep 21 '22 23:09

Lilian A. Moraru


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

like image 36
smaudet Avatar answered Sep 18 '22 23:09

smaudet