Chinaunix

标题: 在虚拟机中,旋转屏幕至水平 [打印本页]

作者: goandroid    时间: 2008-11-24 16:03
标题: 在虚拟机中,旋转屏幕至水平
通过手动的方式:
CTRL+F12,

Rotate Screen from Code
What you learn: You will learn how to rotate the screen (change screen orientation) using code.
[Update]

zhobbs wrote:
Thanks for the tip plusminus, looks like it changed in 0.9:
Java:
Activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_*);
and
Java:
Activity.getRequestedOrientation();
Thanks!
[/Update]
(Just found this code snippet in my ICQ-Log):
Java:
android.view.IWindowManager windowService = android.view.IWindowManager.Stub.asInterface(ServiceManager.getService("window"));
windowService.setOrientation(1);
If I remember right, it is 0-3 for all 4 possible screen-rotations (could not find official constants for it

).
The orientation is even "remembered" if you leave your app to the HOME-Screen.
This is how to get the current Screen-Orientation:
Java:
windowService.getOrientation();

本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u2/85805/showart_1663039.html




欢迎光临 Chinaunix (http://bbs.chinaunix.net/) Powered by Discuz! X3.2