问题描述
有没有一种方法来模拟打开/关闭硬件键盘模拟器?我一定要考,我捕捉使用getResources()的一些变化getConfiguration()keyboardHidden,这将有助于公平的很多。)
Is there a way to simulate opening/closing the 'hardware' keyboard in the emulator?I have to test some changes that I capture using getResources().getConfiguration().keyboardHidden and this would help a fair lot :)
感谢你在前进!
推荐答案
要添加到Samuh的解释(我不知道 - 很好的了解,我还可以模拟开/改变方向关闭硬件键盘),您可以测试景观之间的区别,没有键盘和景观带键盘打开时,通过改变模拟器的AVD的硬件配置:AVD可适当配置可以有一个硬件键盘与否。如果你的模拟器没有硬件键盘,软键盘显示你所期望的,并会为横向模式应该出现,因为它会在横向模式下的手机,没有键盘。
To add to Samuh's explanation (which I didn't know -- good to know that I can still simulate opening/closing the hardware keyboard by changing orientation), you can test the difference between landscape with no keyboard and landscape with keyboard open, by changing the hardware configuration of the emulator's AVD: The AVD can be configured to either have a hardware keyboard or not. If your emulator has no hardware keyboard, the soft keyboard appears as you would expect, and going to landscape mode should appear as it would in landscape mode on a phone with no keyboard.
要配置仿真器AVD充当如果没有硬件键盘,在AVD和放大器; SDK管理器工具,单击新建添加一个新的AVD,选择所需的SDK水平和其他选项,并在硬件部分,增加对键盘支持一个新的属性,并将其设置为无。在AVD模拟器详细信息对话框,这将显示为hw.keyboard =无。
To configure the emulator AVD to act as if it has no hardware keyboard, in the AVD & SDK Manager tool, click "New" to add a new AVD, select your desired SDK level and other options, and under the Hardware section, add a new property for "Keyboard support", and set it to "No". In the AVD emulator "Details" dialog, this will show up as "hw.keyboard = no".
请注意:您还可以修改现有的AVD通过切换它的键盘支持:
Note: you can also modify an existing AVD to toggle its keyboard support by:
- 打开 AVD管理
- 选择 AVD 要编辑
- 点击修改... 右侧
- 在硬件部分,点击新... 右侧
- 在属性组合框中选择键盘支持,然后点击确定
- 同样在硬件部分的键盘支持的值列更改为无 李>
- 最后点击修改AVD 并退出管理器。
- Open the AVD Manager
- Select the AVD you want to edit
- Click on Edit... on the right
- In the Hardware section, click on New... on the right
- In the Property combo box select Keyboard support and click OK
- Again in the Hardware section, change the Keyboard support value column to "no"
- Finally click Edit AVD and exit the Manager.
另外,您也可以编辑< AVD路径> / AVD /< AVD设备名称> .avd / config.ini文件
文件,并修改 hw.keyboard
进入yes或no。在Mac和Linux,一般〜/ .android /
,而在Windows /用户/<使用者名称> /安卓/
。
Alternatively, you can also edit the <avd path>/avd/<AVD device name>.avd/config.ini
file, and changing the hw.keyboard
entry to yes or no. On Mac and Linux, is generally ~/.android/
, and on Windows /Users/<user-name>/.android/
.
,这意味着你可以通过手机在横向模式与键盘开放作为的行为(仿真器配置了硬件键盘),或在横向模式下,没有键盘(仿真器没有配置键盘)。两个小的挫折与此是:1)你不一定能模仿它的外观在横向模式下的设备的的的硬件键盘,但键盘是隐藏的(如果我理解正确的话),并在2)你将不得不运行分别引导两个单独的仿真器或至少两种AVDS,为了测试这两种不同的情况。
Based on Samuh's answer, that means you can check the behavior of the phone being in landscape mode with keyboard open (emulator has a hardware keyboard configured), or in landscape mode with no keyboard (emulator is configured with no keyboard). Two minor frustrations with this are 1) you can't necessarily emulate how it will look in landscape mode on a device that has a hardware keyboard, but the keyboard is hidden (if I understand correctly), and 2) you would have to run two separate emulators or at least two AVDs booted separately, in order to test those two different cases.
这篇关于模拟开/闭硬件键盘在模拟器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!