强制全屏幕的活动,以重新测量/重绘的简历? [英] Force a full screen Activity to remeasure/redraw on resume?

查看:160
本文介绍了强制全屏幕的活动,以重新测量/重绘的简历?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

编辑,以增加更多的细节: (本来问了近两个月前......还没有找到一个解决方案)

Edited to add more details: (originally asked nearly two months ago...still haven't found a solution)

我有一个比较复杂的视图的活动。并不复杂的技术意义上说...有只是很多事情。在这个特定的应用程序的所有活动都设置为全屏NoTitleBar,和他们都设置为横向。我注意到,早在开发时,应用程序是隐藏的,然后恢复,出现了一个罕见的趋势布局滑下垂直好像要腾出空间标题栏和状态栏。

I have an activity with a somewhat complicated view. Not complicated in a technical sense...there's just a lot going on. All activities in this particular app are set to FullScreen NoTitleBar, and they're all set to Landscape orientation. I noticed early on in development when the app is hidden and then resumes, there was an infrequent tendency for the layout to slide down vertically as if to make room for the titlebar and statusbar.

后来的发展中,应用程序现在召唤出各种外部意图。现在我注意到,有更多的倾向于从外部处理解雇意图(如创建一个选择器意图或采摘的图像)恢复时,使同样的转变。我可以使用完全相同的步骤不一致再现它...有时它发生有时没有。看来,如果有测量和布局的不同阶段之间的竞争条件。我认为这些步骤,该系统为我做的检查全屏和notitlebar,并进行必要的转变之一。这可能发生晚在一些情况下

Later on in development, the app now calls out to various external intents. I notice now that there is more of a tendency to make this same shift when resuming from an externally handled fired intent (such as creating a "chooser" intent or picking an image). I am able to reproduce it inconsistently using the exact same steps...sometimes it happens sometimes it doesn't. It seems as if there's a race condition in between various phases of measuring and laying out. I assume that one of these steps that the system is doing for me is checking for fullscreen and notitlebar, and making the necessary shift. This is probably happening late in some cases.

我放了一堆日志记录,并调用无效(),requestLayout(),等想也许赶上了比赛状态,但这个问题似乎外界对我的布局。顶()和底部()我的根布局值始终为0,我的屏幕的高度,分别为,即使当我登录这个当问题发生。

I put a bunch of logging, and calls to invalidate(), requestLayout(), etc trying to maybe catch the race condition, but the problem seems external to my layouts. The top() and bottom() values of my root layout are always 0 and the height of my screen, respectively, even when I'm logging this while the issue is occurring.

有窗口的其他方法,窗口管理器或任何其他系统视图相关的对象,我可以强制一个完整的再次测量,重绘,重新检查当前主题/风格的标志?

Is there some other method of the Window, WindowManager or any other system view-related object that I can force a full remeasure, redraw, re-check for current theme/style flags?

推荐答案

我有完全相同的问题,也尝试了几种aproches(如上面提到的)。 他们没有工作。然而,我发现了以下解决方法:

i had exactly the same problem and also tried several aproches (as the ones mentioned above). None of them worked. However i found the following workaround:

 protected void onResume() {
   super.onResume();
   handler.postDelayed(new Runnable() {
      public void run() {
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                             WindowManager.LayoutParams.FLAG_FULLSCREEN);
      }
   }, 1000);    
 }

视图会做一个简短的闪烁在此过程中,但至少它doensn't保持croped。 一个干净的解决方案仍然需要被发现。然而,这支持你的论点是有某种定时或种族问题。

the view will do a short flicker in this procedure, but at least it doensn't stay croped. A clean solution still needs to be found. However this supports your thesis that there is some kind of timing or race problem.

这篇关于强制全屏幕的活动,以重新测量/重绘的简历?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆