In the manifest file I have this line to my application tag
android:theme="@android:style/Theme.NoTitleBar"
and basically every activity doesn't have a title bar, but for one of the activities I want to show the title bar
I know that to hide the bar I can use this code
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
How can I show title bar from code ?
EDIT PLEASE do not tall me how can I hide the title bar :), I know that, if anybody know how can I show it ?
I know that I can put NoTitleBar in every activity that I want to hide and I can leave it for the one I want to be shown... But that was not my point
For me thous lines of code work perfectly:
Hide:
getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
Show:
getWindow().addFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
use
android:theme="@android:style/Theme.NoTitleBar"
in each activity except the activity where you want to show the title. Dont use this theme in application
attribute
according to your comment you want to make my change to only one place and it seems you dont want to make the chage in only one manifest(!). anywayy you can do another thing
use a BaseActivity Class where use the no title feature and extend it in all classes except the titled activity.
Best way to do this is to reference this Try to use Window.FEATURE_CUSTOM_TITLE
Apparently this doesn't work and any other way seems to always crash
requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
setContentView(R.layout.settings);
activity.setTitle("Settings");
I am sure this is the way to do this via code.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With