Enabling and disabling title bar in android
I want to enable and disable the title bar ba开发者_StackOverflow社区sed on the entry point for the activity. How can i do it(may it be in xml or in code)? Thanks in advance.
you can hide the title bar like this way
//Remove title bar
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
//Remove notification bar
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
or modify in xml file like this way
<activity android:name=".MainActivity"
android:label="@string/app_name"
android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen">
or using style with xml file like this way
<style name="generalnotitle" parent="general">
<item name="android:windowNoTitle">true</item>
</style>
Try this.. its a hack..
titleView = getWindow().findViewById(android.R.id.title);
if (titleView != null) {
ViewParent parent = titleView.getParent();
if (parent != null && (parent instanceof View)) {
View parentView = (View)parent;
parentView.setVisibility(View.GONE);
}
精彩评论