改变布局,而不是重新启动活动在我的Andr​​oid应用程序我的、重新启动、应用程序、布局

2023-09-12 06:03:12 作者:時間蒼白了誓言

我想我的应用程序,从纵向到横向和布局1更改为布局2,但不重新启动该活动。 它从布局1到布局2很好,但每次从纵向到横向和横向到纵向切换时重新启动活动,我想只要运行活动一次,然后它保留下来。

I want my app to go from portrait to landscape and change from layout1 to layout2 but not restart the activity. It goes from layout1 to layout2 nicely, but restarts the activity every time it switches from portrait to landscape and landscape to portrait and i want to just run the activity once then keep it there.

任何帮助是极大的AP preciated谢谢你。

Any help is greatly appreciated thank you.

推荐答案

您可以做到这一点通过添加安卓configChanges =定向您的清单中的活动和处理手动屏幕内容通过覆盖 onConfigurationChanged

You can achieve this by add android:configChanges="orientation" to your activity in manifest and handle the screen contents manually by overriding onConfigurationChanged