我想为我的一些活动隐藏标题栏。问题是,我应用了一个风格,我所有的活动,因此我不能简单地设置主题@android:style/ theme . notitlebar。
使用NoTitleBar主题作为我的样式的父主题将从我的所有活动中删除标题栏。
我可以在某个地方设置无标题样式的项目吗?
我想为我的一些活动隐藏标题栏。问题是,我应用了一个风格,我所有的活动,因此我不能简单地设置主题@android:style/ theme . notitlebar。
使用NoTitleBar主题作为我的样式的父主题将从我的所有活动中删除标题栏。
我可以在某个地方设置无标题样式的项目吗?
当前回答
你可以修改AndroidManifest.xml:
<activity android:name=".MainActivity"
android:label="@string/app_name"
android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen">
或者使用android:theme="@android:style/ theme . black。NoTitleBar"如果你不需要全屏活动。
注意:如果你之前使用了一个'default'视图,你可能也应该把父类从AppCompatActivity改为Activity。
其他回答
你可以修改AndroidManifest.xml:
<activity android:name=".MainActivity"
android:label="@string/app_name"
android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen">
或者使用android:theme="@android:style/ theme . black。NoTitleBar"如果你不需要全屏活动。
注意:如果你之前使用了一个'default'视图,你可能也应该把父类从AppCompatActivity改为Activity。
添加主题@style/ theme . appcompat . light。在AndroidManifest.xml中的NoActionBar
<activity
android:name=".activities.MainActivity"
android:theme="@style/Theme.AppCompat.Light.NoActionBar">
</activity>
我正在使用Android Xamarin,这对我来说很有效。
SupportActionBar.Hide();
SetContentView(Resource.Layout.activity_main);
添加舱单文件,
android:theme="@android:style/Theme.Translucent.NoTitleBar"
添加以下行到您的Java文件,
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
在onCreate()方法中执行此操作。
//Remove title bar
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
//Remove notification bar
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
//set content view AFTER ABOVE sequence (to avoid crash)
this.setContentView(R.layout.your_layout_name_here);
这是指活动。