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 Creating the Screen Layout Setting Padding

Kevin Natanael
Kevin Natanael
2,177 Points

I am using android 2.3. In the xml, I am using constraint layout, and it doesn't show how much is the padding.

the padding atributtes won't show up, maybe because i'm using the constraint layout. I want to know how to change the padding in the constraint layout

1 Answer

Jonathan Grieve
MOD
Jonathan Grieve
Treehouse Moderator 91,252 Points

Hi Kevin,

You should be able to edit your padding properties in design view of any layout. I've just added one myself in my copy of Android Studio 2.3.1 and it is in Constraint view.

Once done you should look for this XML in text view

        android:padding="5dp"

For greater control, you can type the following directly into Text view for greater control of where you apply padding to your visual elements

        android:padding="5dp"
        android:paddingBottom="5dp"
        android:paddingEnd="5dp"
        android:paddingLeft="5dp"
        android:paddingRight="4dp"
        android:paddingStart="5dp"
        android:paddingTop="5dp"

Try experimenting with these and different units like dp or sp to see which works best for you :)