Search code examples
androidxmlandroid-layoutandroid-actionbar

Removing Action Bar (Android Studios)


Newer templates provided by android studio make use of themes.xml instead of styles.xml and changing parent="Theme.MaterialComponents.DayNight.DarkActionBar" to parent="Theme.AppCompat.Light.NoActionBar" dosen't remove the action bar. do you know how can I remove the action bar in the XML files? ==> also I tried your suggestions of changing parent="Theme.MaterialComponents.DayNight.DarkActionBar" to parent="Theme.MaterialComponents.DayNight.NoActionBar" in both theme.xml files and this is the outcome: https://i.sstatic.net/heimI.png as you can see in the image action bar is only getting bigger. is it bugged? what do you think? My XML Files: values\themes.xml:

 <resources xmlns:tools="http://schemas.android.com/tools">
        <!-- Base application theme. -->
        <style name="Theme.Idcard" parent="Theme.MaterialComponents.DayNight.NoActionBar">
            <!-- Primary brand color. -->
            <item name="colorPrimary">@color/white</item>
            <item name="colorPrimaryVariant">@color/purple_500</item>
            <item name="colorOnPrimary">@color/white</item>
            <!-- Secondary brand color. -->y
            <item name="colorSecondary">@color/teal_200</item>
            <item name="colorSecondaryVariant">@color/teal_700</item>
            <item name="colorOnSecondary">@color/black</item>
            <!-- Status bar color. -->
            <item name="android:statusBarColor" tools:targetApi="l">?attr/colorPrimaryVariant</item>
            <!-- Customize your theme here. -->
        </style>
    </resources>

night\themes.xml:

<resources xmlns:tools="http://schemas.android.com/tools">
    <!-- Base application theme. -->
    <style name="Theme.Idcard" parent="Theme.MaterialComponents.DayNight.NoActionBar">
        <!-- Primary brand color. -->
        <item name="colorPrimary">@color/purple_200</item>
        <item name="colorPrimaryVariant">@color/purple_700</item>
        <item name="colorOnPrimary">@color/black</item>
        <!-- Secondary brand color. -->
        <item name="colorSecondary">@color/teal_200</item>
        <item name="colorSecondaryVariant">@color/teal_200</item>
        <item name="colorOnSecondary">@color/black</item>
        <!-- Status bar color. -->
        <!-- Customize your theme here. -->
    </style>
</resources>

and here is a link to the app files on Github: code files


Solution

  • After trying everything I finally re-installed Android Studios and it fixed right away! it obviously was a bug. So if ever you got into problems like that, witch things don't work as they should, re-installing Android Studios is always an option.