简体   繁体   English

在更改android中的方向后,保持布局更改持久

[英]Keep layout changes persistent after changing orientation in android

I am changing visibility of button at run time. 我正在改变运行时按钮的可见性。 but when ever I am changing orientation I am getting default layout defined in XML file 但是当我改变方向时,我得到了XML文件中定义的默认布局

So what should I do to keep the changes done in layout at runtime 那么我该怎么做才能在运行时保持布局中的更改

Thanks... 谢谢...

not sure if it could work. 不确定它是否可行。 adding the following into your AndroidManifest.xml which can prevent the activity from being restart when you change orientation. 将以下内容添加到AndroidManifest.xml中可以防止在更改方向时重新启动活动。

activity .......... android:configChanges="orientation|screenSize" 活动.......... android:configChanges =“orientation | screenSize”

Inside file: 内部文件:

AdroidManifest.xml AdroidManifest.xml

<activity .. android:configChanges="orientation|screenSize" /> <activity .. android:configChanges =“orientation | screenSize”/>

It works for me very well. 它对我很有用。 That's what I was looking for. 这就是我想要的。 Now, my Changes stay alive after I changed the screen-layout-orientation. 现在,在我更改了屏幕布局方向后,我的更改仍然存在。

Thank you Ksharp, very much. 非常感谢Ksharp。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM