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 trialMUZ140584 Heredity Mbundire
4,979 PointsIn this challenge we are going to add some margins to a ListView. Start by declaring a new dimension in dimens.xml below
help
<resources xmlns:android="http://schemas.android.com/apk/res/android">
android:horizontal_margin = "10dp"
</resources>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/item_background_color" >
<ImageView
android:id="@+id/itemImage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:contentDescription="@string/content_desc_item"
android:src="@drawable/ic_item" />
</RelativeLayout>
</LinearLayout>
8 Answers
Adlight Sibanda
5,701 Pointshello there!
this did the trick
<dimen name="horizontal_margin">10dp</dimen>
Ricky Sparks
22,249 Pointsshould look something like this below....
Ricky Sparks
22,249 Points<dimen name="activity_horizontal_margin">16dp</dimen>
MUZ140681 Tatenda Muchaziwepi
4,340 PointsThis should pass task 1 & 2
<resources xmlns:android="http://schemas.android.com/apk/res/android"> <dimen name="horizontal_margin">10dp</dimen> <dimen name="vertical_margin">6dp</dimen> </resources>
James Simshaw
28,738 PointsHello,
It looks like you're trying to add the parameter android:horizontal_margin = "10dp" to the main <resource> tag. What you are wanting to do here is add a child dimen tag with the name horizontal_margin with the value of 10dp. Let me know if you need further assistance and please provide updated code so I can give suggestions based upon where you currently are at.
MUZ140584 Heredity Mbundire
4,979 PointsBummer! Don't forget to add the 'dimen' element inside the 'resources' element am stil stuck
James Simshaw
28,738 PointsHello,
From the message I have to guess that you added your dimen element outside of the the <resources></resources> block. It needs to come between the two. If that doesn't help, please post your current code so we can assist you further.
Blessing Mashingaidze
4,839 Pointsstill stuck adlight
Ricky Sparks
22,249 PointsLook at your dimens.xml in android studio to see the way it is written.