How to scale Droid emulator to correct physical size

Quickly share your Android Code Snippets here...

How to scale Droid emulator to correct physical size

Postby XCaffeinated » Wed Dec 02, 2009 1:32 am

[align=center]How to scale Droid emulator to correct physical size[/align]

This snippet assumes you have already created your AVD as a Droid AVD either via the Android SDK and AVD Manager from Eclipse, or the command line with something like the following:

[font=Courier New]>android create AVD -n MyDroidAVD -t 4 --skin WVGA854[/font]

The -t option is system specific. In my case -t 4 means to use the Android 2.0 platform; yours might be different depending on how many platforms you have installed. You should check this with:

[font=Courier New]>android list targets[/font]

and use the -t value appropriate for your purposes. Note use of the WVGA854 skin.

[hr]
This is what we want (full size):
[align=center]Image[/align]

To get the emulator's display screen (as it appears on your monitor) to be the same form factor as the Droid handset, do the following:

1) Get your monitor dpi (from the manufacturer spec, or just measure it – it'll be close enough).

2) Calculate the scaled dpi.

From this link (about 3/4 of the way down), we see that the default setup for the WVGA854 skin is 4.1 inches (diagonal), but the Droid handset is only 3.7 inches (diagonal). We need to scale the monitor dpi (from step 1) to take this difference into account. As an example, say your monitor dpi is 100 (mine is exactly 100, but 96 and 98 are typical values), we'd get:

100dpi * (3.7in/4.1in) = 90dpi

3) Enter the scaled dpi value as an emulator option.

Assume we calculated a scaled dpi of 90 in step 2.

Eclipse users: Run->Run Configurations..., Target tab, under Emulator Launch Parameters add:

[font=Courier New]-scale 90dpi[/font]

to the Command Line Options textbox. You may have to adjust the size of the dialog box to see the textbox; it's at the very bottom:

[align=center]Image[/align]

Command line users: Add '-scale 90dpi' to the end of your normal emulator command line:

[font=Courier New]>emulator <your usual options> -scale 90dpi[/font]
(Do not leave a space between the number and the 'dpi' suffix).

There is much more information on scaling and screen independence here. In particular, see Table 1 (screens supported) and How to Test Your Application on Multiple Screens.

One small caveat: remember that there is no way to make more pixels on your development monitor. The Droid handset has 854 pixels crammed into the same space represented on your monitor by only about a third of that number, so the image quality on your monitor is going to be pretty poor. However, the size will be exactly correct for what you'd see on the Droid handset, which makes it perfect for testing UI form factor and human interface features.

Hint of the Day: Use Alt-Enter to toggle full screen display of your emulator.

Hope this helps!
XCaf
XCaffeinated
Developer
Developer
 
Posts: 25
Joined: Sun Nov 29, 2009 10:16 pm

Top

Postby Boni2k » Fri Jan 01, 2010 5:29 pm

I'm not having "Additional Emulator Option"...?

--> there's a screen when starting the emulator manually where you can set dpi.
But it doesn't work for me. Emulator doesn't start afterwards...
Boni2k
Experienced Developer
Experienced Developer
 
Posts: 88
Joined: Sun Dec 20, 2009 9:46 pm

Postby XCaffeinated » Sat Jan 02, 2010 6:02 pm

Hi Boni2k,

In order to see the Additional Emulator Command Line Options textbox, you need to expand the Run/Debug Configurations dialog box:
Image

Hover your cursor over the bottom edge of the dialog, as indicated by the coach mark in the diagram above, and it will turn into a double arrow cursor. You should be able to drag the bottom of the dialog down so that you can see the textbox.

Also, if you would like to set Eclipse so that the emulator automatically uses the scale option for all your projects, you can do so in Window->Preferences->Android->Launch. Fill in the Default emulator options textbox with your scale value. This can be a convenience if you mostly target the Droid platform.

Hope this helps!
XCaf
XCaffeinated
Developer
Developer
 
Posts: 25
Joined: Sun Nov 29, 2009 10:16 pm

Postby StaryLiu » Mon Jan 11, 2010 6:20 am

I'd like to share a tool for run emulator you just need to click the button.

it can install apk,uninstall apk,get your avd list and run emulator at your assign scale
Attachments
AdbTools_en.zip
(143.46 KiB) Downloaded 270 times
Fox, you'll know who am I.
E-mail : 179715162@qq.com
User avatar
StaryLiu
Freshman
Freshman
 
Posts: 7
Joined: Mon Dec 28, 2009 6:54 am
Location: ShenZhen,China

Top

Return to Code Snippets for Android

Who is online

Users browsing this forum: No registered users and 9 guests