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 a Simple Android App (2014) Creating the Screen Layout Using a Fullscreen Theme

Danny Malaeb
Danny Malaeb
2,459 Points

My Styles.xml is different from the video. I am now stuck. (2:41)

My Styles.xml is different from the video. I am now stuck. (2:41)

I follow the instructions but my code appears different Style.xml. I follow the instructions but removing .DarkActionBar at the end, and readd .(and push ctrl+space). It auto fills but there is no option "NoActionBar" option. It currently looks like...

<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">

I tried copying the video manually by removing it completely and putting in...

<style name="AppTheme" parent="Theme.Holo.Light.NoActionBar">

But the line appears red with "Cant resolve symbol Theme.Holo.Light.NoActionBar". I also still get an action bar in my emulator but all the changes is the colour, so I supposed it defaulted to "Theme.Holo.Light" as that one works ok.

I also tried editing the end by removing DarkActionBar and adding NoActionBar on the original line eg.

<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">

But all that did was crash the App in my emulator :(.

I did try using the theme button in the design tab to but it had no effect.

How can I fix this, or is there a work around I can do to proceed with this course?

5 Answers

Danny Malaeb
Danny Malaeb
2,459 Points

Ok so I found a work around. I'm now using...

<style name="AppTheme" parent= "Theme.AppCompat.Light.DarkActionBar">
        <!-- Customize your theme here. -->
        <item name="android:windowActionBar">false</item>
        <item name="android:windowNoTitle">true</item>
    </style>

...to remove the bar.

So if anyone else has this issue, I guess they can use this.

If anyone knows the actual solution, please tell me. A bit sad I couldn't identify the problem :(.

Thanks,

Thank you Danny! This solution works for me!! Thank you so much!

I solved this by changing FunFactsActivity.java (or whatever you called the app) and styles.xml.

At the top of FunFactsActivity.java:

import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.view.MenuItem;

public class FunFactsActivity extends Activity

and then it should accept

<style name="AppTheme" parent="android:Theme.Holo.Light.NoActionBar">

in styles.xml

Jacob Bergdahl
Jacob Bergdahl
29,118 Points

"Theme.AppCompat.Light.NoActionBar" should work fine. Are you sure it's crashing because of that line? Did you change anything else that might cause the app to crash? Make sure to take a close look at what the error message say!

It does not work. Maybe it worked a year and a half ago when this track was created, but it does not work anymore.

I followed every step to the letter up until this point. I used the above suggestion of

Edit: Apparently it just REALLY does not want to let me enter this code, style name="AppTheme" parent= "Theme.AppCompat.Light.DarkActionBar"_

and that made the action bar disappear. I am now on the step where a second activity is added, but the action bar is still on that page.

I came back here and attempted to use "Theme.AppCompat.Light.NoActionBar" but that causes my app to crash.

I attempted deleting my styles.xml file and replacing it verbatim with the one shown in the video but that causes the following errors:

In activity_main.xml:

'''

<?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.example.sean.interactivestory.MainActivity">

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


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

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

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

'''

Error:(14, 24) No resource found that matches the given name (at 'theme' with value '@style/AppTheme.AppBarOverlay').

in activity_story.xml

'''

<?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.example.sean.interactivestory.StoryActivity">

<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>

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

<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"/>

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

'''

Error:(14, 24) No resource found that matches the given name (at 'theme' with value '@style/AppTheme.AppBarOverlay').

Error:(21, 29) No resource found that matches the given name (at 'popupTheme' with value '@style/AppTheme.PopupOverlay').

Please advise as to what I am doing wrong and how to fix.

Thank you.

Danny Malaeb
Danny Malaeb
2,459 Points

Thanks for responding Jacob.

If I change it back to...

<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">

It works perfect again. But if I try...

<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">

I get these errors under Messages.

C:\Users\Bobo\AndroidStudioProjects\FunFacts\app\src\main\res\values\styles.xml Error:Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat.Light.NoActionBar'. Error:Execution failed for task ':app:processDebugResources'.

com.android.ide.common.internal.LoggedErrorException: Failed to run command: C:\Users\Bobo\Downloads\android-studio-bundle-windows\android-studio\sdk\build-tools\android-4.4W\aapt.exe package -f --no-crunch -I C:\Users\Bobo\Downloads\android-studio-bundle-windows\android-studio\sdk\platforms\android-19\android.jar -M C:\Users\Bobo\AndroidStudioProjects\FunFacts\app\build\intermediates\manifests\debug\AndroidManifest.xml -S C:\Users\Bobo\AndroidStudioProjects\FunFacts\app\build\intermediates\res\debug -A C:\Users\Bobo\AndroidStudioProjects\FunFacts\app\build\intermediates\assets\debug -m -J C:\Users\Bobo\AndroidStudioProjects\FunFacts\app\build\generated\source\r\debug -F C:\Users\Bobo\AndroidStudioProjects\FunFacts\app\build\intermediates\libs\app-debug.ap_ --debug-mode --custom-package cumdumpsterproductions.funfacts -0 apk --output-text-symbols C:\Users\Bobo\AndroidStudioProjects\FunFacts\app\build\intermediates\symbols\debug Error Code: 1 Output: C:\Users\Bobo\AndroidStudioProjects\FunFacts\app\build\intermediates\res\debug\values\values.xml:555: error: Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat.Light.NoActionBar'. Information:BUILD FAILED

I strongly think the "NoActionBar" is the cause as DarkActionBar works ok.

It does not crash anymore but it still shows the bar in the emulator and that "No Resource" error still appears :S.

EDIT: There is nothing I can recall that I changed aside from clicking the Display tab and attempting to change the theme to no Action from there.

EDIT2: Also code completion (ctrl+space) hasn't NoActionBar or even Theme.Holo. If I type those manually, that's where the trouble start.

I've entered my workaround in the next post.

Danny Malaeb
Danny Malaeb
2,459 Points

I get an API level 13 (current min is 10) error :S.