3

I have a very simple question to ask

I have a relativeLayout with its width set to 100dp. Now whatever the screen will be, xhdpi, lpdi, hdpi etc it will remain 100dp. However if i change the width to 100Sp what will be the difference?

Muhammad Umar
  • 11,391
  • 21
  • 91
  • 193
  • check out [this link](http://stackoverflow.com/a/2025541/2345913) and [this link](http://developer.android.com/guide/topics/resources/more-resources.html#Dimension) – CRUSADER Jun 06 '13 at 11:27
  • You should not use `sp` in your layouts, because it is intended to work with text only :) – a.bertucci Jun 06 '13 at 11:29

1 Answers1

3

Nothing will change and yet everything because sp and dp is the same for normal phone configurations but if the user increase text size sp will scale larger or smaller, while dp will remain the same.

See more here.

Community
  • 1
  • 1
Warpzit
  • 27,966
  • 19
  • 103
  • 155
  • What If I want to app to detect the change. E.g If i set 100 dp width on mdpi It should auto set its width to 200DP on xhdpi? – Muhammad Umar Jun 06 '13 at 11:33
  • @MuhammadUmar well one way would be to simply make 2 different layouts. 1 for mdpi and 1 for xhdpi. You can read more about that here: http://developer.android.com/guide/practices/screens_support.html under Using configuration qualifiers – Warpzit Jun 06 '13 at 11:36