Android 如何调整 AVD 模拟器的大小(在 Eclipse 中)?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2359895/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-20 05:31:58  来源:igfitidea点击:

How to resize the AVD emulator (in Eclipse)?

androideclipseemulation

提问by Scott Saunders

I'm writing my first Android app for a small business that has some Droid phones. I set up an AVD for the phone with the right resolution: 854 pixels high.

我正在为拥有一些 Droid 手机的小型企业编写我的第一个 Android 应用程序。我为手机设置了一个分辨率正确的 AVD:854 像素高。

I'm working on a MacBook Pro with a max screen resolution 900 pixels high, so when the emulator starts up, the bottom is cut off.

我正在使用最大屏幕分辨率为 900 像素的 MacBook Pro,因此当模拟器启动时,底部被切断。

Is there a way to scale the emulator display down to 75% or something so that it fits on my screen? Any other solution (other than running everything on the phone itself)?

有没有办法将模拟器显示缩小到 75% 或其他东西,以便它适合我的屏幕?任何其他解决方案(除了在手机本身上运行所有内容)?

采纳答案by emmby

From within Eclipse:

从内部Eclipse

  1. Go to Window > Android SDK and AVD Manager > Virtual Devices

  2. Selectthe AVD you want to launch and click Start

  3. Checkthe Scale display to real sizebutton

  4. Enterhow big you want it to appear in inchesand pressLaunch. For this to work, you'll have to also enter a reasonable approximation of your mac's screen resolution. I'm using 7 inches and 113 dpi for my 13" Macbook Pro, but you may be able to get away with 8 or 9 inches.

  1. Window > Android SDK and AVD Manager > Virtual Devices

  2. 选择要启动的 AVD 并单击Start

  3. 检查Scale display to real size按钮

  4. 输入您希望它以英寸为单位显示的大小然后Launch。为此,您还必须输入 mac 屏幕分辨率的合理近似值。我的 13 英寸 Macbook Pro 使用 7 英寸和 113 dpi,但您可能可以使用 8 或 9 英寸。

回答by Walter Heck

This is actually possible from your project as well, no need to start the emulator through the AVD manager:

这实际上也可以从您的项目中实现,无需通过 AVD 管理器启动模拟器:

  1. Go to Run > Run Configurations... > (Select your application on the left hand side) > (Click the "Target"tab on the right hand side).

  2. At the bottom there, you'll see Emulator launch parameters. In the additional emulator command line options, add '-scale 0.75'(to make the screen 75% of full size)

  1. 转到Run > Run Configurations... >(在左侧选择您的应用程序)>(单击"Target"右侧的选项卡)。

  2. 在那里的底部,你会看到Emulator launch parameters。在 中additional emulator command line options,添加'-scale 0.75'(使屏幕为全尺寸的 75%)

Next time you start the emulator it will have scaled properly.

下次启动模拟器时,它将正确缩放。

回答by mDiaz93

There is also a way to re size the emulator through a windows command prompt.

还有一种方法可以通过 Windows 命令提示符重新调整模拟器的大小。

  1. From command prompt run: telnet localhost 5554
  2. window scale 0.75
  3. quit
  1. 从命令提示符运行: telnet localhost 5554
  2. window scale 0.75
  3. quit

Assuming there is one emulator running with on port 5554.

假设有一个模拟器在端口 5554 上运行。

回答by K5 Studios

The telnet answer above is great for Android Studio developers. I just wanted to add that the window scale command will take either a scale factor OR the dpi which may be easier for many people (measure once and it should work for you ADV which are 1dp:1 pixel)

上面的 telnet 答案非常适合 Android Studio 开发人员。我只是想补充一点,窗口缩放命令将采用比例因子或 dpi,这对许多人来说可能更容易(测量一次,它应该适用于你的 ADV,即 1dp:1 像素)

telnet localhost PortNumOfAVD
window scale 96dpi
quit

Note telnet is not installed on windows by default anymore.

注意 telnet 不再默认安装在 Windows 上。

回答by Ankit

For Changing the window size of the Android Emulator

用于更改 Android 模拟器的窗口大小

Append the parameter -scale --<scale factor>to the Emulator launch parameters. In eclipse, put it in the field "Additional Emulator Command Line Options" within the Run Configuration.

将参数附加-scale --<scale factor>到模拟器启动参数。在 Eclipse 中,将其放在运行配置中的“附加模拟器命令行选项”字段中。

Allowed scale factors are those between 0.1 and 3, although the most common will probably be -scale 0.5.

允许的比例因子介于 0.1 和 3 之间,但最常见的可能是-scale 0.5

回答by asiby

If you are working with Eclipse, than here's is what you can do if the size of the emulator is too big for you screen:

如果您正在使用 Eclipse,那么如果模拟器的大小对于您的屏幕来说太大,您可以执行以下操作:

  1. Run > Run Configurations
  2. Pick the "Target" tab
  3. Scroll down to "Additional Emulator Command Line Options" and put in: "-scale 0.7" or another number
  1. 运行 > 运行配置
  2. 选择“目标”选项卡
  3. 向下滚动到“其他模拟器命令行选项”并输入:“-scale 0.7”或其他数字

This will keep the AVD scaled even if it is started automatically by Eclipse.

即使 AVD 由 Eclipse 自动启动,它也会保持缩放。

Enjoy

享受

回答by CommonsWare

If you launch your emulator outside of Eclipse, using the androidcommand, you will be able to scale the screen as part of the launch process. Not sure how to do that in Eclipse, though.

如果您在 Eclipse 之外启动模拟器,使用该android命令,您将能够在启动过程中缩放屏幕。不过,不确定如何在 Eclipse 中做到这一点。

回答by Drag0

I definitely recommend running the emulator through terminal or command line because it allows you for much better control.

我绝对建议通过终端或命令行运行模拟器,因为它可以让您更好地控制。

For example, if you want to run emulator in different size, you just need to run it like this.

例如,如果你想运行不同大小的模拟器,你只需要像这样运行它。

~/Android/Sdk/tools/emulator -scale 0.35 -avd Nexus_5_API_23

Nexus_5_API_23 corresponds to existing AVD on my host computer. When you create different Android Virtual Devices, you can just replace it with name of your device and it works. So basically you just run emulator from Android SDK's tools directly. You can also add other parameters like netdelay, netspeed etc.

Nexus_5_API_23 对应于我主机上现有的 AVD。当您创建不同的 Android 虚拟设备时,您只需将其替换为您的设备名称即可。所以基本上你只是直接从 Android SDK 的工具运行模拟器。您还可以添加其他参数,如 netdelay、netspeed 等。

回答by Pradyumna Swain

The command to open in Command Prompt is given below

在命令提示符中打开的命令如下

  1. emulator -avd [- []] ... [-].for details see http://developer.android.com/tools/help/emulator.html
  1. 模拟器 -avd [- []] ... [-]。有关详细信息,请参阅http://developer.android.com/tools/help/emulator.html

To open a desired size emulator window follow the below command

要打开所需大小的模拟器窗口,请按照以下命令

  • emulator -avd "AVD_Name "-scale "Scale_Value"-dpi-device "dpi"
  • 模拟器 -avd "AVD_Name "-scale "Scale_Value"-dpi-device "dpi"

Example:

示例

  • emulator -avd "AVD_Name "-scale auto -dpi-device 160/200. with dpi-device value 200
  • 模拟器 -avd "AVD_Name "-scale auto -dpi-device 160/200。 dpi-device 值为 200

with dpi-device value 160

dpi-device 值为 160

So just change the dpi-value according to your need. Hope u enjoy.

所以只需根据您的需要更改 dpi 值。希望你喜欢。

回答by Pedro Lopes

Another option would be to use the GenyMotionemulator, where you can actually resize the emulator window in real time. It is also much faster than the stock emulator.

另一种选择是使用GenyMotion模拟器,您可以在其中实时调整模拟器窗口的大小。它也比股票模拟器快得多。