Search code examples
androidtitlebar

Showing the title bar


I have an app that switches between full screen and normal screen for a certain condition. I have successfully done this with the notification but the TITLE BAR still remains hidden after I set it back from full screen to normal screen mode. So HOW DO I SHOW THE TITLE BAR AFTER HIDING IT?

EDIT:

I have come across answers where they make a custom title bar and switch between its visibility but thats not what I want.

CODE:

if(ScreenReceiver.wasScreenOn) {
    Toast toast=Toast.makeText(this, "screen was on", Toast.LENGTH_LONG);
    toast.show();
    getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);  
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
    setContentView(R.layout.resume);
} else { 
    Toast toast=Toast.makeText(this, "screen was off", Toast.LENGTH_LONG);
    toast.show();
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);  
    getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
    setContentView(R.layout.main);
}

Solution

  • try this

     this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                                  WindowManager.LayoutParams.FLAG_FULLSCREEN);
    
    
    /// custom tittle bar declaration 
    final boolean customTitleSupported = requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
    
    /// custom tittle bar creation ///....
        if (customTitleSupported) {
            getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.tittle_bar);
        }
        final TextView myTitleText = (TextView) findViewById(R.id.title_bar);
        if (myTitleText != null) {
            myTitleText.setText("Categories");
        }