在android中启用和禁用标题栏
我想根据活动的入口点启用和禁用标题栏。我怎么做(可以是xml或代码)?在android中启用和禁用标题栏,android,android-layout,android-manifest,Android,Android Layout,Android Manifest,我想根据活动的入口点启用和禁用标题栏。我怎么做(可以是xml或代码)? 提前感谢。您可以这样隐藏标题栏 //Remove title bar this.requestWindowFeature(Window.FEATURE_NO_TITLE); //Remove notification bar this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLA
提前感谢。您可以这样隐藏标题栏
//Remove title bar
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
//Remove notification bar
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
<activity android:name=".MainActivity"
android:label="@string/app_name"
android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen">
<style name="generalnotitle" parent="general">
<item name="android:windowNoTitle">true</item>
</style>
或者像这样在xml文件中修改
//Remove title bar
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
//Remove notification bar
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
<activity android:name=".MainActivity"
android:label="@string/app_name"
android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen">
<style name="generalnotitle" parent="general">
<item name="android:windowNoTitle">true</item>
</style>
或者像这样对xml文件使用样式
//Remove title bar
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
//Remove notification bar
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
<activity android:name=".MainActivity"
android:label="@string/app_name"
android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen">
<style name="generalnotitle" parent="general">
<item name="android:windowNoTitle">true</item>
</style>
真的
您可以这样隐藏标题栏
//Remove title bar
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
//Remove notification bar
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
<activity android:name=".MainActivity"
android:label="@string/app_name"
android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen">
<style name="generalnotitle" parent="general">
<item name="android:windowNoTitle">true</item>
</style>
或者像这样在xml文件中修改
//Remove title bar
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
//Remove notification bar
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
<activity android:name=".MainActivity"
android:label="@string/app_name"
android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen">
<style name="generalnotitle" parent="general">
<item name="android:windowNoTitle">true</item>
</style>
或者像这样对xml文件使用样式
//Remove title bar
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
//Remove notification bar
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
<activity android:name=".MainActivity"
android:label="@string/app_name"
android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen">
<style name="generalnotitle" parent="general">
<item name="android:windowNoTitle">true</item>
</style>
真的
试试这个。。这是一种恶作剧
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);
}
试试这个。。这是一种恶作剧
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);
}
我希望标题栏仅在某些情况下显示在活动中。因此,如果我设置NoTitleBar主题,那么在所有情况下,标题栏都会从活动中完全移除。但我想在某些情况下启用标题栏,在某些情况下禁用。如果我尝试设置上述主题并在代码中使用requestWindowFeature(Window.FEATURE\u CUSTOM\u TITLE)启用它,它会引发一个异常,您无法将自定义标题与其他标题功能组合。对于需要标题栏的单个活动,只需在清单文件中为它们提供自己的主题即可。这很好,但他试图摆脱新的风格。风格让我毛骨悚然……:)我希望标题栏仅在某些情况下显示在活动中。因此,如果我设置NoTitleBar主题,那么在所有情况下,标题栏都会从活动中完全移除。但我想在某些情况下启用标题栏,在某些情况下禁用。如果我尝试设置上述主题并在代码中使用requestWindowFeature(Window.FEATURE\u CUSTOM\u TITLE)启用它,它会引发一个异常,您无法将自定义标题与其他标题功能组合。对于需要标题栏的单个活动,只需在清单文件中为它们提供自己的主题即可。这很好,但他试图摆脱新的风格。风格让我毛骨悚然……:)