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) Improving Our Code Dynamically Changing the Background Color

James N
James N
17,864 Points

i am getting a "rendering problems" error

i am getting the following error: Rendering Problems Missing styles. Is the correct theme chosen for this layout? Use the Theme combo box above the layout to choose a different layout, or fix the theme style references. Couldn't resolve resource @dimen/activity_horizontal_margin (4 similar errors not shown) "@dimen/activity_horizontal_margin" in attribute "paddingLeft" is not a valid format. (Edit) (4 similar errors not shown) Failed to find style 'textViewStyle' in current theme (12 similar errors not shown)

my code for activity_fun_facts.xml is: <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".FunFactsActivity" android:id="@+id/relativeLayout" android:background="#ff000000" android:clickable="false">

<TextView
    android:text="Did You Know?"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/textView"
    android:textSize="24sp"
    android:textColor="#80ffffff" />

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Ants stretch when they wake up in the morning"
    android:id="@+id/factTextView"
    android:layout_centerVertical="true"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true"
    android:textSize="24sp"
    android:textColor="@android:color/white" />

<Button
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:text="Show another fun Xbox fact!"
    android:id="@+id/showFactButton"
    android:background="@android:color/white"
    android:layout_alignParentBottom="true"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true" />

</RelativeLayout>

2 Answers

Andrew West
Andrew West
3,245 Points

Check your dimens.xml file under FunFacts\app\src\res\values\dimens.xml and make sure it looks like the following, if there's a typo at 50dp it might cause problems.

dimens.xml

<resources>
    <!-- Default screen margins, per the Android Design guidelines. -->
    <dimen name="activity_horizontal_margin">50dp</dimen>
    <dimen name="activity_vertical_margin">50dp</dimen>
</resources>

Did you post your entire activity_fun_facts.xml file? If so you appear to be missing the RelativeLayout portion that encapsulates all the TextView tags.

activity_fun_facts.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingLeft="@dimen/activity_horizontal_margin" // If these show 50dp or 64dp that's fine
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    android:paddingBottom="@dimen/activity_vertical_margin"
    tools:context=".FunFactsActivity"
    android:background="#ff51b46d"
    android:id="@+id/relativeLayout">

    //Text view stuff in here

</RelativeLayout>

I got the same problem, it can be resolved via changing the http://stackoverflow.com/a/29993270

however, what I mean it seems the installation is just not optimal and something has went wrong somewhere. I wouldn't want to change that variable on every blank project I make and run into probably more problems further down the road.

I'm still searching for an answer myself as well!