2

I am a beginner in android, I have a basichat doubt For setting font size what is most preferred in android sp, px or pt. Any help will appreciate

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
  • This question might help: https://stackoverflow.com/questions/2025282/what-is-the-difference-between-px-dp-dip-and-sp-on-android – TuringTux May 29 '17 at 05:27
  • 1
    Possible duplicate of [What is the difference between "px", "dp", "dip" and "sp" on Android?](https://stackoverflow.com/questions/2025282/what-is-the-difference-between-px-dp-dip-and-sp-on-android) – TuringTux May 29 '17 at 05:28
  • This is a duplicate of https://stackoverflow.com/questions/23981260/should-use-sp-instead-of-dp-for-text-sizes – EKN May 29 '17 at 06:52

4 Answers4

3

sp: Scale Independent Pixel, scaled based on user’s font size preference.Fonts should use sp.
sp is preferrable for setting font size.

Nithya
  • 52
  • 8
1

Sp. Sp is scaled pixels. It scales with the text size the user sets. This means that people with problems seeing can set a larger base font size, and your text will scale with that setting. It makes it easier for those people to use the app.

Gabe Sechan
  • 90,003
  • 9
  • 87
  • 127
1

SP Scale-independent Pixels

Scale-independent Pixels - this is like the dp unit, but it is also scaled by the user's font size preference. It is recommended you use this unit when specifying font sizes, so they will be adjusted for both the screen density and user's preference.

for Refrence more

Ratilal Chopda
  • 4,162
  • 4
  • 18
  • 31
1

Sp for font size

dp for any view width, height, margin, padding etc.

px not recommended in android development

for more detail read this

Mukesh Y.
  • 869
  • 1
  • 16
  • 36