Android 方向改变故障
当相当快地改变屏幕方向时,或者当背景上有沉重的东西时,我遇到了奇怪的问题。当我在 onConfigurationChanged
上调用 setContentView(R.layout.main);
(我自己处理方向更改)时,在屏幕旋转 android 片刻后,将布局设置为与方向。例如 - 当您更改方向布局时,像这样纵向>横向,但有时,就我而言,它会像这样纵向>纵向(当手机已经处于横向位置时)> ;风景。
有时您甚至没有注意到这一点,有时屏幕会缩小到大约 1/3 秒。 嗯,这并不是什么大问题,但在我的活动中,我有 Coverflow 小部件(基于 Gallery),并且为了使其在大多数屏幕上看起来不错,我根据父容器大小设置图像大小(在 onSizeChanged 的小部件),并且当方向发生如上所述的变化时,coverflow 小部件会选择错误尺寸。
我现在看到的唯一方法是在方向更改时调用 onCreate(我不能这样做,因为在线填充了大量 UI),或者在初始化 UI 时设置延迟(这很难看)。
所以我想知道是否有 setContentView()
或其他任何回调,这样我就可以知道布局何时真正准备好,以便我可以初始化 UI。
或者也许还有另一种方法?
PS:由于某种原因,这个故障主要发生在 Desire HD 上。
I encountered weird problem when changing screen orientation rather fast, or when something heavy goes on background. When I call setContentView(R.layout.main);
on onConfigurationChanged
(I handle orientation changes myself),after screen is rotated android for a brief moment sets layout for opposite to orientation. For example - when you change orientation layout changes like this Portrait>Landscape, but sometimes, in my case, it goes like this Portrait>Portrait(when phone is already in in landscape position)>Landscape.
Sometimes you dont even notice this, and sometimes screen shrinks to about 1/3 for a second.
Well, It's not really a big deal, but in my activity I have Coverflow widget (based on Gallery) and to make it look good on most of the screens I set image sizes based on parent container size (in onSizeChanged
of widget), and when orientation changes goes as described above coverflow widget picks up a wrong size.
The only way I see now is to either call onCreate on orientation change (Which I cant do, because of heavy UI populated online), or set a delay on initializing UI (which is ugly).
So I wonder, is there any callback of setContentView()
or anything else, so I could know when layout is actually ready, so I can init UI.
Or maybe there is another way around?
PS: For some reason this glitch mostly occurs on Desire HD.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
AndroidManifest.xml
这是您所期望的吗?
AndroidManifest.xml
Is it what you expect?