Hide ActionBar title just for one activity

烂漫一生 提交于 2019-12-01 13:25:22

Set the theme on your activity in the manifest.

<activity
    android:name=".MyActivity"
    android:theme="@style/MainActivityTheme" />

You probably want to create a sub-theme which hides the action bar:

<style name="AppTheme.NoActionBar">
    <item name="android:windowActionBar">false</item>
</style>

and then apply it to your activity in the manifest like so:

<activity android:name="NonActionBarActivity"
          android:theme="@style/AppTheme.NoActionBar" />

Using the dot notation (AppTheme.NoActionBar) makes this NoActionBar theme inherit everything from AppTheme and override the setting on android:windowActionBar. If you prefer you can explicitly note the parent:

<style name="AppThemeWithoutActionBar" parent="AppTheme">
    <item name="android:windowActionBar">false</item>
</style>

Also, if you're using the AppCompat libraries, you probably want to add a namespace-less version to the sub-theme.

    <item name="windowActionBar">false</item>

If you want to remove actionbar title then just remove label attribute from <activity> tag in your manifest file.

Such as,

<activity
        android:name=".YourActivityName"
        android:label="@string/title" />

And after removing,

<activity
        android:name=".YourActivityName" />

Done!

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!