如果我以纵向模式进入纵向布局,并且如果以横向模式进入横向模式布局,则我有2个布局用于纵向和其他景观。 然而; 如果我进入纵向模式并将屏幕旋转到横向,则不会调用横向布局,手机会旋转纵向布局,从而产生奇怪的布局(如果我在使用横向时旋转它,则相同)。 所以当我在运行时旋转手机时,如何使应用程序调用正确的布局。 谢谢,
I have 2 layouts one for portrait and other for landscape, if I enter in portrait mode the portrait layout is called, and if I enter in landscape mode the landscape mode layout is called. However; if I enter in portrait mode and rotate the screen to landscape the landscape layout is not called the phone rotates the portrait layout resulting a strange layout (same if I rotate it when using landscape). So how to make the application call the right layout when i rotate the phone upon run time. Thanks,
最满意答案
可能你在AndroidManifest.xml中为你的Activity设置了android:configChanges =“orientation”,这意味着你必须自己在Activity.onConfigurationChanged中处理方向更改。 从清单中删除android:configChanges,活动将在方向更改时重新创建,并且您的代码应该开始工作。
Probably you have android:configChanges="orientation" set for you Activity in your AndroidManifest.xml, which means you'll have to handle orientation changes yourself in Activity.onConfigurationChanged. Remove android:configChanges from the manifest and the activity will be recreated on orientation change and you code should start working.
在运行时更改布局方向(Change layout orientation on run time)如果我以纵向模式进入纵向布局,并且如果以横向模式进入横向模式布局,则我有2个布局用于纵向和其他景观。 然而; 如果我进入纵向模式并将屏幕旋转到横向,则不会调用横向布局,手机会旋转纵向布局,从而产生奇怪的布局(如果我在使用横向时旋转它,则相同)。 所以当我在运行时旋转手机时,如何使应用程序调用正确的布局。 谢谢,
I have 2 layouts one for portrait and other for landscape, if I enter in portrait mode the portrait layout is called, and if I enter in landscape mode the landscape mode layout is called. However; if I enter in portrait mode and rotate the screen to landscape the landscape layout is not called the phone rotates the portrait layout resulting a strange layout (same if I rotate it when using landscape). So how to make the application call the right layout when i rotate the phone upon run time. Thanks,
最满意答案
可能你在AndroidManifest.xml中为你的Activity设置了android:configChanges =“orientation”,这意味着你必须自己在Activity.onConfigurationChanged中处理方向更改。 从清单中删除android:configChanges,活动将在方向更改时重新创建,并且您的代码应该开始工作。
Probably you have android:configChanges="orientation" set for you Activity in your AndroidManifest.xml, which means you'll have to handle orientation changes yourself in Activity.onConfigurationChanged. Remove android:configChanges from the manifest and the activity will be recreated on orientation change and you code should start working.
发布评论