void android.app.Activity.setRequestedOrientation(int requestedOrientation)
官方API解釋:
Change the desired orientation of this activity. If the activity is currently in the foreground or otherwise impacting the screen orientation, the screen will immediately be changed (possibly causing the activity to be restarted). Otherwise, this will be used the next time the activity is visible.
中文大意:
改變activity的期望的方向。如果activity 目前在前台或以其他方式影響屏幕的方向,屏幕將立即被改變(可能導致活動重新啟動)。否則,這將在activity 下一次可見時使用。
//設橫屏
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);