In my manifest file, I set
android:screen orientation="portrait"
for my MainActivity. I did this so that my initial tutorial can work well. After the initial tutorial has concluded, I now want my MainActivity to behave normally ie when the user rotates the device let it change by itself(the default behaviour). Is there a way to that
Remove android:screenorientation="portrait"
from Manifest First .
From Run-time
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
Also add this in your manifest file (under activity):
android:configChanges = "orientation"
http://techblogon.com/android-screen-orientation-change-rotation-example/
从清单中删除android:screenorientation="portrait"
,并确保设备上的旋转功能处于开启状态
Remove android:screenOrientation="portrait" from manifest file and make sure your device setting isint set to "locked rotation"
also android:screenOrientation="portrait" works for whole manifest file level and also it works individually for activity tag level in manifest, so if android:screenOrientation="portrait" is added in activity tag level , remove it from there too.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.