Force an Android activity to always use landscape

2019-01-02 17:12发布

I am using the Android VNC viewer on my HTC G1. But for some reason, that application is always in landscape mode despite my G1 is in portrait mode. Since the Android VNC viewer is open source, I would like know how is it possible hard code an activity to be 'landscape'. I would like to change it to respect the phone orientation.

14条回答
初与友歌
2楼-- · 2019-01-02 17:50

Press CTRL+F11 to rotate the screen.

查看更多
大哥的爱人
3楼-- · 2019-01-02 17:53

Use the ActivityInfo (android.content.pm.ActivityInfo) in your onCreate method before calling setLayout method like this

this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
查看更多
登录 后发表回答