Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get 1:1 pixels on android emulator?

I created an AVD without screen scaling, but the pixels do not match my screen.

is there any work around for this?

enter image description here

Screen is configured as 720 wide, but shows as 413 on my screen.

Edit: a little more experiementation, motivated by @Fallenreaper answer:

If I load a 500px wide image in the browser, it's still larger than the screen (which was supposed to be 720px wide).

enter image description here

Here is the 500px image, with two screen shots, scrolled to the right to show it's larger than the 720px screen.

edit 2: this may be related to this http://www.quirksmode.org/blog/archives/2010/04/a_pixel_is_not.html

like image 965
gcb Avatar asked Oct 04 '22 02:10

gcb


1 Answers

When you start the emulator from Android Virtual Device Manager, you must check Scale display to real size, and then specify Screen Size (in) and Monitor dpi that calculates to a Scale value of 1.0 (or 0.50 if you're on a retina display on OSX).

In my case, I specified a 4.7 in Screen Size and a 160 Monitor dpi, which yielded a 0.50 Scale. When I take a screenshot of my emulator, it is now pixel-for-pixel what I would expect to see on the device.

You can also specify a command-line option -scale 1.0 when starting the emulator from the command-line.

If your emulator is already running, you can adjust the scale with the emulator console by sending window scale 1.0. This renders too large for me to use on my Retina MBP.

Discover your running emulators with adb devices. You should see output like this:

$ adb devices
List of devices attached 
emulator-5554   device

Then, you can connect to the device and send the scale command:

$ telnet localhost 5554
Trying ::1...
telnet: connect to address ::1: Connection refused
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
Android Console: type 'help' for a list of commands
OK
window scale .50
OK
^]
telnet> quit
Connection closed.

And you can do it in a script with netcat:

$ echo 'window scale 0.50' | nc localhost 5554
like image 122
Heath Borders Avatar answered Oct 07 '22 20:10

Heath Borders