I want my title bar to be hidden when I turn my device to landscape. I have seen the XML option to hide the title bar, and the following example of doing it programmatically:
//Remove title bar
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
//Remove notification bar
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
BUT, I am using configChanges
parameter for orientation
and screenSize
, so my activity is not re-created again when it is orienting to landscape (I'm doing this for some reasons). So I cannot use the above methods as these calls need to be made before setContentView()
.
So any ideas? Thank you.
first check your device orientation by using following code
The current configuration, as used to determine which resources to retrieve etc, as available from the Resources' Configuration object as:
Then do the necessary coding related to hide title bar and notification bar.
was searching for an answer, ended up here, put the pieces together and here they are:
In your "AndroidManifest.xml", in the activity tag you can specify "NoTitleBar" in the theme property so that it will always hide the title:
Assuming you have defined
configChanges
for theActivity
in the manifest then you can achieve your issue overridingonConfigurationChanged
method:You will have to use
getSupportActionBar()
instead ofgetActionBar()
if using the support library.