方向变化 - 背景
如果手机处于横向模式,我的应用程序会通过加速度计识别这一点 (我使用加速度计,因为我确实有 3 个不同的方向和其他变化值)。 我使用以下代码更改方向:
myLayout.setBackgroundResource(R.drawable....); setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
当方向更改时,我会看到扭曲的图像几秒钟。其原因显然是BackgroundRessource 在方向改变之前就被改变了。
我尝试使用布局土地和布局端口文件夹,结果是我在横向方向上总是出现扭曲的图像。
我怎样才能避免这种情况?
If the phone is in landscape mode my app recognizes this with the accelerometer
(I use the accelerometer, because i do have 3 differnt orientations and other values for the change).
I change the orientation with the following code:
myLayout.setBackgroundResource(R.drawable....); setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
When the orientation gets changed I see a distorted image for a few seconds. The reason of this is apparently that the BackgroundRessource gets changed before the change of orientation.
I have tried to use layout-land and layout-port folders with the consequence that i have in the landscape orientation always a distorted image.
How can I avoid this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我也有类似的问题,只是切换到横向时出现黑屏。看到有人提到创建一个新的可绘制土地文件夹,这可能对你有用......但对我不起作用。
我刚刚从这里的一位成员那里得到了这个答案。试一试。
I have a similar problem except that i just get a black screen when switching to landscape. Saw someone mention creating a new drawable-land folder which might work for you...didnt work for me tho.
Just got this answer myself from a member here. Give it a shot.