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

Binyamin Friedman
Binyamin Friedman
14,615 Points

dp vs. sp

What is the difference? When do you use one or the other? When I used them they produced the same results.

A very general way of thinking about it is: SP -- Scale-Independent Pixels -- is relevant to the SIZE of the screen. DP -- Density-Independent Pixels -- is relevant to the RESOLUTION of the screen.

This doesn't explain everything about SP/DP, but it's a good general guideline.

1 Answer

Jason Anders
MOD
Jason Anders
Treehouse Moderator 145,860 Points

Hi Binyamin,

If you do a Google Search on this, you'll come up with many resource, like this Stack Overflow Thread.

Keep coding! :dizzy: