问题
I would like to convert/adapt my application to Android 4.0. To do so I plan to use the ActionBar on devices that support it. All Android version >= 3.0 do so. Furthermore devices that do not have a hardware menu button seem to show an "menu" button on the actionbar automatically.
When I test my application on the emulator using API level 13 this does work as expected... ... but somehow I'm not able to setup the emulator to behave the same way while emulating a phone on API level 14 (Android 4.0). When I try to set "Hardware Back/Home keys" to false there are no buttons at all (not on the screen and not keypad provided by the emulator).
I have seen on some screenshots and videos from the "Galaxy Nexus" that it is showing an "menu" button on the ActionBar as well ... like Honeycomb tablets do it, but I'm somehow not successful to do the same with the emulator which makes it a bit more complicated to understand how my UI will work on Andoid 4.0 phones.
EDIT: Here is an image that is showing the On-Screen back and home buttons I would like to see in the emulator:
回答1:
It seems the issue was fixed with the latest update of the SDK (R16). Just update your SDK and ADT to R16 and create a new emulator using the updated Android 4.0 system image.
回答2:
When you create new emulator there is grid Hardware, and there you can add options Hardware home and back buttons and Hardware keyboard. So, create new emulator and look at your "Galaxy Nexus" :)
Unfortunately you can't change this properties for existing emulator.
回答3:
After upgrading to R16 I could only get the on-screen buttons to appear if I created an emulator using the WXGA720 resolution.
Here is my complete config.ini file:
hw.sdCard=yes
hw.mainKeys=no
hw.lcd.density=320
disk.cachePartition.size=256MB
hw.cpu.arch=arm
skin.name=WXGA720
sdcard.size=512M
abi.type=armeabi-v7a
image.sysdir.2=system-images\android-16\armeabi-v7a\
image.sysdir.1=add-ons\addon-google_apis-google-16\images\armeabi-v7a\
hw.gps=yes
skin.path=platforms\android-16\skins\WXGA720
hw.keyboard.lid=no
hw.cpu.model=cortex-a8
vm.heapSize=48
hw.ramSize=1024
Hopefully this helps someone.
回答4:
The soft keys showed up for me when I set hw.mainKeys
to no
:
- Open
$HOME/.android/avd/YOURS.avd/config.ini
- Set
hw.mainKeys=no
(This was covered in a deleted answer; don't know why it was deleted.)
回答5:
If your application includes functionality that would respond to a menu button, the menu button will be added to the black bottom bar.
If you are having trouble seeing this in the emulator, you can do a bit of a workaround by setting it to a tablet resolution (I use 1280x800) and observing your menu button behavior there, as it should be the same as on the phone version.
来源:https://stackoverflow.com/questions/7873532/how-to-configure-the-android-emulator-to-show-onscreen-buttons-like-the-new-gala