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 Implementing Designs for Android Customizing a ListView for the Inbox Adding Margins to ListViews

In this challenge we are going to add some margins to a ListView. Start by declaring a new dimension in dimens.xml below

help

dimens.xml
<resources xmlns:android="http://schemas.android.com/apk/res/android">
           android:horizontal_margin = "10dp"

</resources>
list_item.xml
<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

hello there!

this did the trick

<dimen name="horizontal_margin">10dp</dimen>

Ricky Sparks
Ricky Sparks
22,249 Points

should look something like this below....

Ricky Sparks
Ricky Sparks
22,249 Points

<dimen name="activity_horizontal_margin">16dp</dimen>

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

Hello,

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.

Bummer! Don't forget to add the 'dimen' element inside the 'resources' element am stil stuck

Hello,

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.

still stuck adlight

Ricky Sparks
Ricky Sparks
22,249 Points

Look at your dimens.xml in android studio to see the way it is written.