Force a full screen Activity to remeasure/redraw on resume?

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

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.

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.

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?

Answers


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);    
 }

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.


Need Your Help

Asp.Net MVC 5 bind parameter exclusively from body

asp.net asp.net-mvc asp.net-mvc-5 model-binding

I want to prevent posting sensitive data via url query string to a MVC 5 application.

Get transformed coordinates with canvas

javascript transform transformation html5-canvas

If I use a transformation function like translate/rotate on a canvas, then all points are transformed when passed to any canvas function. This works like a charm, but is there also a way to simply ...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.