I want my android application to be only run in portrait mode? How can I do that?
相关问题
- How can I create this custom Bottom Navigation on
- Bottom Navigation View gets Shrink Down
- How to make that the snackbar action button be sho
- Listening to outgoing sms not working android
- How to create Circular view on android wear?
相关文章
- android开发 怎么把图片放入drawable的文件夹下
- android上如何获取/storage/emulated/下的文件列表
- androidStudio有个箭头不认识
- SQLite不能创建表
- Windows - Android SDK manager not listing any plat
- Animate Recycler View grid when number of columns
- Why is the app closing suddenly without showing an
- Android OverlayItem.setMarker(): Change the marker
There are two ways,
android:screenOrientation="portrait"
for each Activity in Manifest Filethis.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
in each java file.Old post I know. In order to run your app always in portrait mode even when orientation may be or is swapped etc (for example on tablets) I designed this function that is used to set the device in the right orientation without the need to know how the portrait and landscape features are organised on the device.
Works like a charm!
NOTICE: Change
this.activity
by your activity or add it to the main activity and removethis.activity
;-)In Android Manifest File, put attribute for your
<activity>
thatandroid:screenOrientation="portrait"
I use
It is helpful if you do not want to support up side down portrait mode.
In the manifest, set this for all your activities:
In the manifest, set this for all your activities:
Let me explain:
android:configChanges="orientation"
you tell Android that you will be responsible of the changes of orientation.android:screenOrientation="portrait"
you set the default orientation mode.