简体   繁体   English

在从布局和布局土地更改方向时更改片段布局

[英]Change Fragment layout on orientation change from layout and layout-land

I'he tried for this answer but its disappears my view on change orientation. 我尝试了这个答案,但是我对变革取向的看法消失了。

thanks for help 感谢帮助

You just need to create a Fragment class, call it from Activity.Then create layout-land folder,put same layout file in both layout and layout-land folder.Now you can use background according to your requirement for portrait and landscape mode. 您只需要创建一个Fragment类,从Activity中调用它即可。然后创建layout-land文件夹,在layout和layout-land文件夹中放入相同的布局文件。现在,您可以根据纵向和横向模式的需要使用背景。 In Manifest 在清单中

<activity android:name="com.example.MainActivity" >

You don't need to use onConfigurationChanged() for this operation,this will automatically call xml from layout in portrait mode and from layout-land in landscape mode. 您不需要使用onConfigurationChanged()进行此操作,这将自动从纵向模式下的布局和横向模式下的布局区域调用xml。

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

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