Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Android Build an Interactive Story App (Retired) User Input Hiding the ActionBar with an App Theme

Nishant Jee
Nishant Jee
844 Points

Unable to remove Action Bar. Below is the Code that i have used.

styles:-

<resources>

<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.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>

<style name="AppTheme.NoActionBar">
    <item name="windowActionBar">false</item>
    <item name="windowNoTitle">true</item>
</style>

<style name="AppTheme.AppBarOverlay" parent="Base.ThemeOverlay.AppCompat.Dark" />

<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />

</resources>

styles.xml(v21) :-

<resources>>

<style name="AppTheme.NoActionBar">
    <item name="windowActionBar">false</item>
    <item name="windowNoTitle">true</item>
    <item name="android:windowDrawsSystemBarBackgrounds">true</item>
    <item name="android:statusBarColor">@android:color/transparent</item>
</style>

</resources>>

In the content.xml i have selected the theme AppTheme.NoActionBar

Still not able to remove the action bar. Please help.

Thanks

2 Answers

Γ‰lvio Sousa
Γ‰lvio Sousa
4,452 Points

Hi there,

You need to change your activity_main.xml and delete some lines of code. Here is my code. Basically in only need to include the content_main.

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true"
    tools:context="com.elviosousa.interactivestory.MainActivity">

    <include layout="@layout/content_main" />

</android.support.design.widget.CoordinatorLayout>
chris linder
chris linder
5,921 Points

<style name="AppTheme.AppBarOverlay" parent="Base.ThemeOverlay.AppCompat.Dark" />

replace with

<style name="AppTheme.AppBarOverlay" parent="Base.ThemeOverlay.AppCompat.DarkNoActionBar" />