3

I have seen some people using sp for margins like:

android:layout_marginLeft="40sp"

While many have been using dp, like:

android:layout_marginLeft="40dp"

Could anyone please confirm which is better between these two and which should be used when? Any help would be highly appreciated.

user1903022
  • 1,065
  • 1
  • 12
  • 19

1 Answers1

7

sp for font sizes, dp for everything else. sp stands for Scale-independent Pixels, dp stands for dip=density independent pixels. Detailed explanation

Community
  • 1
  • 1
Mustafa Berkay Mutlu
  • 1,752
  • 1
  • 23
  • 32