Android设定屏幕只竖屏或只横屏的两种方式

方式一:

在AndroidMainfest.XML中的activity属性设定中

加入android:screenOrientation="portrait",屏幕设定为竖屏

加入android:screenOrientation="landscape",屏幕设定为横屏

方式二:

在onCreate方法中,super.onCreate(savedInstanceState);后

setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);设定为竖屏

setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);设定为横屏

发布了74 篇原创文章 · 获赞 2 · 访问量 7万+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章