![](/img/trans.png)
[英]surfaceview orientation without main.xml or androidmanifest.xml
[英]Orientation Layout not changing for landscape after adding android:configChanges=“orientation|screenSize” in AndroidManifest.xml
我的应用具有不同的纵向和横向布局。 当我更改屏幕方向时,应用程序活动会以当前方向布局重新启动。我尝试添加以下内容:
<activity android:name=".MainActivity"android:configChanges="orientation|screenSize">
这在我的AndroidManifest.xml
文件中,它可以工作。 但它并没有改变我的方向布局。 我怎样才能解决这个问题??
有两种方法供您参考。
1.1 更改AndroidManifest.xml
将以下内容添加到 AndroidManifest.xml 文件中的活动中:
景观: android:screenOrientation=”landscape”
肖像: android:screenOrientation=”portrait”
1.2 setRequestedOrientation
(代码设置)
景观: setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
肖像: setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.