Home » Android » java – Force a full screen Activity to remeasure/redraw on resume?

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

Posted by: admin June 15, 2020 Leave a comment


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?

How to&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() {
   handler.postDelayed(new Runnable() {
      public void run() {
   }, 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.


In my case this behavior was triggered by resume from lock screen. No idea why but after adding empty overloaded function it was fixed (but I tested it only on my HTC Wilfire). It may be a different bug thou.

public void onWindowFocusChanged(boolean hasFocus) {
    /* Workaround a probable Android bug with fullscreen activities:
     * on resume status bar hides and black margin stays, 
     * reproducible half of the time when coming back from lock screen 
     * (tested on HTC Wildfire)
     * No idea why but this empty overload method fixed it.


I’m not sure if it’ll work, but you might want to try this in that method:


If that doesn’t work on it’s own, try adding to the onDraw(Canvas) method the instructions necessary to remove the title bar and do similar adjustments your activity might be doing at startup.

Hope that helps.


Hey Rich,
I had the exact same problem. I fixed it by setting these options in the manifest XML (it seems the API interface is a little buggy). Details here: http://thedevelopersinfo.wordpress.com/2009/10/21/making-an-fullscreen-activity/



Have you set FullScreen NoTitleBar in your manifest or in code?
If you use code, it may be that it is getting rendered before your code kicks in?

<application android:label="@string/app_name" android:icon="@drawable/icon" android:theme="@android:style/Theme.NoTitleBar.Fullscreen">

I understand that you can set themes on individual activities in an application. Do you? and do they conflict with your application settings?


Have you tried this in onResume()?

                                WindowManager.LayoutParams.FLAG_FULLSCREEN );


I have found a Solution to this:

    protected void onResume() {
        Log.e("", "onResume");

        //this is a simple Splash with "Game paused" Text inside! in my main.xml
        final LinearLayout gamePause_text = (LinearLayout) findViewById(R.id.gamePause_text);
        OnGlobalLayoutListener asdf = new OnGlobalLayoutListener(){
            public void onGlobalLayout() {
                Log.e("", "onGlobalLayout");
                gameSurface.onResume(); //OpenGL Surface onResume();


I Fixed it by setting the theme for application rather than for individual activities.

        android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen" >

This worked for me. This problem occurs if the next Activity we launch isnt a Full screen Activity and current Activity is a Full screen Activity.