Search code examples
androidandroid-layoutandroid-4.4-kitkatandroid-titlebar

Hiding Title Bar in Android 4.4 (Specifically Galaxy Tab 4)


I have been trying to hide the Title Bar of my app for 2 days now.

I have tried all the usual methods suggested by the web and SDK: requestWindowFeature(Window.FEATURE_NO_TITLE); and using Themes: @android:style/Theme.Black.NoTitleBar.Fullscreen and many different types.

Nothing seems to work - so I am hoping that someone out there can elaborate their technique... here is what I have as suggested by the Android Studio:

public class AFRLeadFormActivity extends DroidGap {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    int currentApiVersion = android.os.Build.VERSION.SDK_INT;
    final int flags = View.SYSTEM_UI_FLAG_LAYOUT_STABLE
            | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
            | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
            | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
            | View.SYSTEM_UI_FLAG_FULLSCREEN
            | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;

    // This work only for android 4.4+
    if (currentApiVersion >= 19) {
        getWindow().getDecorView().setSystemUiVisibility(flags);
        // Code below is for case when you press Volume up or Volume down.
        // Without this after pressing valume buttons navigation bar will
        // show up and don't hide
        final View decorView = getWindow().getDecorView();
        decorView
                .setOnSystemUiVisibilityChangeListener(new View.OnSystemUiVisibilityChangeListener() {
                    @Override
                    public void onSystemUiVisibilityChange(int visibility) {
                        if ((visibility & View.SYSTEM_UI_FLAG_FULLSCREEN) == 0) {
                            decorView.setSystemUiVisibility(flags);
                        }
                    }
                });
    }
    super.loadUrl("file:///android_asset/www/index.html");
}
}

As you can see, we are using PhoneGap, and so that might be throwing a wrench into the works - but honestly, there is not enough verbose output for me to know why this won't work!

Help me obi stackoverflow-bi, you're my only hope.


Solution

  • It seems this is an issue with PhoneGap, you need to add the line

    <preference name="fullscreen" value="true" />
    

    to your res/xml/config.xml (note that config.xml must sit on that path).