Because my laptop's screen resolution is 1366x768, significant portions of the top and bottom of the Android emulator window (including the caption bar and window controls) get cut off when using display modes like WVGA800. Of course, once the emulator has started up, you can telnet into it (e.g. telnet localhost 5554) and run the 'window scale' command to scale the window (e.g. window scale 0.8 will scale to 80% of the original size), but you need to do this every time it's launched. Alternatively, you can start the emulator with the desired options via command line and then select it from MonoDroid's 'Select Device' dialog box. However, I've found this to be a constant annoyance when dealing with several emulated devices (and especially when inadvertently, but repeatedly, closing them and then having to restart).

Of course, the ideal solution would be for Xamarin to provide a place in the Mono for Android Settings dialog (under Tools/Options in Visual Studio) to specify additional command line options to be passed to the emulator. I've logged an enhancement request but, as a workaround in the meantime, I've created a small Windows app that intervenes between MonoDroid and the Android emulator. For those who would find this useful, it can be downloaded here. This tool allows you to launch available (or select running) emulated devices from the MonoDroid add-in as normal but, at the same time, be able to customize or fine-tune the parameters that get passed to the emulator. After downloading, follow the simple steps below:

  1. Go into your android-sdk\tools folder and rename emulator.exe to something like emulator-android.exe.
  2. Copy the emulator.exe and emulator.exe.config files (after extracting from the downloaded zip file) into the android-sdk\tools folder. Ensure that the value of the EmulatorPath key in the emulator.exe.config file correctly reflects the name and location of the renamed executable (specifically if you chose to rename it to something other than emulator-android.exe). Also, make sure that you update the path if your Android SDK was installed to the default 'Program Files' location or elsewhere. (Note that mine is installed in a folder called 'apps' because recent versions of the Android SDK tools do not work correctly if there is a space in the path.)
  3. Add any additional parameters you'd like included (see Emulator Startup Options for a list) to the EmulatorParameters key in the config file. I say 'additional' because the tool adds these to the existing parameters already being passed by MonoDroid.

MonoDroid will typically start the emulator with parameters resembling the following:

-partition-size 512 -avd Android22 -prop monodroid.avdname=Android22

If the EmulatorParameters key value in the emulator.exe.config file is set to "-scale 0.8", it will get added to this list of parameters. However, you can also override existing values. For example, setting EmulatorParameters to "-scale 0.8 -partition-size 256" will add the scale parameter but it will also replace the existing partition size of 512 (specified by MonoDroid) with 256.

Here's an example of what the appSettings section of the emulator.exe.config file looks like:

<appSettings>
    <add key="EmulatorPath" value="C:\apps\Android\android-sdk\tools\emulator-android.exe" />
    <add key="PassThruParameters" value="true" />
    <add key="EmulatorParameters" value="-scale 0.8" />
    <add key="DebugPrompt" value="true" />
</appSettings>

The DebugPrompt key is initially set to "true" so that you can verify that the path and parameters that will be passed are correct. Once confirmed, simply set this value to false to prevent the dialog box from displaying in the future.  Once this is done the tool will be completely transparent.

Download emulator-tool.zip (3.6 KB).

2171 views