Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.
Frank Fox978 Points
Code Challenge - Handling a Lack of Data - Step 2
So, I've tried this a variety of ways, but while I get the "bummer!" error, the preview doesn't give any details on why I'm wrong; I get a blank white page. I've cleared my browser cache, so that's not causing the lack of Preview mode.
On Step 2, the requirement is as follows: Now add the android:layout_width and android:layout_height attributes and set both equal to the value that shrinks the Button around its content (the text on the Button, in this case).
Here is my XML code: <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" tools:context=".MainActivity" >
<Button> android:layout_width="wrap_content" android:layout_height="wrap_content" </Button>
So, I feel like wrap_content is correct based on what that does to the element. That being said, I've tried using match_parent for both, or even one as wrap_content and one as match_parent, swapped those, and still get the "bummer" error. I feel like the assignment is only to setup the layouts, so I'm lost here (and totally because of the lack of the Preview window). Any insight on this?
there isn't anything wrong with your wrap_content. There is however, something wrong with where you are defining them.
Something between the
<Button> tags is a child element of the button (just like when you put the button between the two
<LinearLayout> tags to say it's inside the linear layout). To define attributes about the button, we must put this before the closing
> of the opening button tag. So something like below:
<Button android:layout_width="wrap_content" android:layout_height="wrap_content" > </Button>
Hope that helps!
Frank Fox978 Points
Ah! Thanks, Liam. I totally didn't grasp the concept of wrapping it into the tag itself. Thanks again!