'How to hide toolbar in android?
I'm really new on android and working on a small project using one of the google templates; the tabbed activity with tabs...is there a way to hide the title section (tabbedExample) and keep only the tabs?
styles.xml
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
<style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
</resources>
Manifiest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="c.example.jinzunza.tabstoolbars">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:theme="@style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Solution 1:[1]
You can simply hide the toolbar putting this in your activity, into the oncreate method:
getSupportActionBar().hide();
Solution 2:[2]
For Activity:
getSupportActionBar().hide();
For Fragment in Java:
((MainActivity) requireActivity()).getSupportActionBar().hide();
For Fragment in kotlin:
(requireActivity() as MainActivity).supportActionBar!!.hide()
Solution 3:[3]
set this theme in your styles.xml file:
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
Solution 4:[4]
You should try this.requestWindowFeature(Window.FEATURE_NO_TITLE); in your onCreate()
Or even simpler, set your theme to: @android:style/Theme.NoTitleBar
The very similar question was answered here
You should find more answers there.
Solution 5:[5]
Use this on create method:
getActionBar().hide();
Solution 6:[6]
this helped me
supportActionBar?.hide();
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Tomerikoo |
| Solution 2 | Tomerikoo |
| Solution 3 | Ümañg ßürmån |
| Solution 4 | |
| Solution 5 | Tomerikoo |
| Solution 6 | Naveed AppsWala |

