Home > other >  Removing Action Bar (Android Studios)
Removing Action Bar (Android Studios)

Time:09-16

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.stack.imgur.com/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

CodePudding user response:

Use parent="Theme.MaterialComponents.DayNight.NoActionBar" instead of parent="Theme.AppCompat.Light.NoActionBar"

<style name="Theme.Pine" parent="Theme.MaterialComponents.DayNight.NoActionBar">
    <!-- Primary brand color. -->
    <item name="colorPrimary">@color/qGreen</item>
    <item name="colorPrimaryVariant">@color/qGreen</item>
    <item name="colorOnPrimary">@color/white</item>
    <!-- Secondary brand color. -->
    <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>

CodePudding user response:

If you have:

<style name="Theme.YourApp" parent="Theme.MaterialComponents.DayNight.DarkActionBar">

You simply keep the DayNight but change DarkActionBar to NoActionBar at the end for both XML files. (themes.xml and themes.xml(night))

Thus it should look like this in both folder:

<style name="Theme.YourApp" parent="Theme.MaterialComponents.DayNight.NoActionBar">

CodePudding user response:

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.

  • Related