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

arminder khinda
arminder khinda
2,357 Points

App Theme Rendering Error

I am trying to hide the Action Bar with the latest Android Studio, but for some reason, it is not hiding. The android version that I have is newer than the one in the video, so it is not matching. Please help

2 Answers

Charlene Allfrey
Charlene Allfrey
5,865 Points

If you are using the most up to date version of Android Studio you may need to remove some code from the activity_main.xml file in the layout folder. I had to remove the following code to get the Action Bar and email icon to be removed from mine

<android.support.design.widget.AppBarLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:theme="@style/AppTheme.AppBarOverlay">

    <android.support.v7.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:background="?attr/colorPrimary"
        app:popupTheme="@style/AppTheme.PopupOverlay" />

</android.support.design.widget.AppBarLayout>

<android.support.design.widget.FloatingActionButton android:id="@+id/fab" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="bottom|end" android:layout_margin="@dimen/fab_margin" android:src="@android:drawable/ic_dialog_email" />

Hope that helps :-)

Charlene Allfrey
Charlene Allfrey
5,865 Points

Don't forget to check the MainActivity.java file for additional code that may need to be removed for the tool bars otherwise once you remove the code from the layout file the project will fail to compile.

arminder khinda
arminder khinda
2,357 Points

Yes I figured it out, thank you Charlene. Appreciate it!

Tristan Smith
Tristan Smith
3,171 Points

Hi Arminder,

Have you modified the styles.xml file in the res/values folder?

Mine looks like this

<!-- styles.xml -->
<resources>

    <!-- Base application theme. -->
    <!-- TODO: Modify the line below to change the theme/remove ActionBar. -->
    <style name="AppTheme" parent="Theme.AppCompat.DayNight.NoActionBar">
        <!-- Customize your theme here. -->
        <item name="colorPrimary">@color/colorPrimary</item>
        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
        <item name="colorAccent">@color/colorAccent</item>
    </style>

</resources>

You'll want to change what it says after "parent=". Try going into that file, deleting everything up until "Theme.", then press CTRL+Space. You'll be provided with a list of available themes in a drop down, select the theme you want to use and go from there.

I encourage you to re-watch the video, some things may be different, but with a little problem solving and you'll find what you need. :-)

I hope that helps! But if it doesn't, please feel free to give a bit more information, we can help from there.