Hide ActionBar Android

Issue

I don´t know why this code is not working it should be easy I looked for asnwers and all of them say same. I want to hide the action bar in my android app. This is my Manifest.xml:

<?xml version"1.0" encoding"utf-8"?>
<manifest xmlns:android"http://schemas.android.com/apk/res/android" 
          android:versionCode"1" 
          android:versionName"1.0" 
          package"com.companyname.nucleo">
  <uses-sdk android:minSdkVersion"21" android:targetSdkVersion"30" />
  <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">
  </application>

  <uses-permission android:name"android.permission.ACCESS_NETWORK_STATE" />
</manifest>

And here is my styles.xml:

<resources>

    <!-- Base application theme. -->
    <style name"AppTheme" parent"Theme.MaterialComponents.Light.DarkActionBar">
        <!-- Customize your theme here. -->
        <item name"colorPrimary">@color/colorPrimary</item>
        <item name"colorPrimaryDark">@color/colorPrimaryDark</item>
        <item name"colorAccent">@color/colorAccent</item>
        <item name  "android:windowActionBar">false</item>
        <item name  "android:windowNoTitle">true</item>
    </style>

</resources>

Thank you for your help.

Solution

Just change the parent atribute to add “…NoActionBar“.

Like this:

    <style name"AppTheme" parent"Theme.MaterialComponents.Light.NoActionBar">
        <!-- Customize your theme here. -->
        <item name"colorPrimary">@color/colorPrimary</item>
        <item name"colorPrimaryDark">@color/colorPrimaryDark</item>
        <item name"colorAccent">@color/colorAccent</item>
    </style>

Answered By – David Zarzoso Moreno

Leave a Comment