0

In my App, I set font sizes and run my Nexus 4. Everything is ok. But in some phones, Font size is bigger than i set. For example, in Samsung A5 2016, Font sized is 3 times bigger than Nexus 4.

Nexus 4 screen: 768 x 1280 pixels, 5:3 ratio (~318 ppi density)

A5 screen: 1080 x 1920 pixels, 16:9 ratio (~424 ppi density)

As I know, When a phone has better resolution, Everything goes smaller not bigger!

I have just one Layout folder for all resolutions and have two values folders for setting sizes for different resolutions:

values-xhdp  : for Nexus 4

and

values-xxhdp  : for Samsung A5

When i decrease font sizes in values-xxhdp folder, Samsung A5 shows fonts in proper size. I set font sizes in sp unit.

What I confused is that already I was thinking that in values-xxhdp folder I have to increase values because is this for high resolution phone, Not decreasing... What happening? What i should do?

Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
Fcoder
  • 9,066
  • 17
  • 63
  • 100

2 Answers2

0

Scaled pixels change according to the user set font size preferences. Read about screen and resolution support.

Hasan Saykın
  • 138
  • 1
  • 8
  • In emulator it behaves normally and fonts goes smaller in high resolution emulator. but in samsung A5 that has higher resolution that Nexus 4, fonts goes very bigger... – Fcoder Nov 08 '17 at 19:36
  • Maybe A5 is set to big font in the settings, and so your sp value is affected by it? – Hasan Saykın Nov 08 '17 at 19:39
  • You should define UI elements in dp as suggested by the link above. And use sp for text size. – Hasan Saykın Nov 08 '17 at 19:42
  • but other apps fonts is normal. just my app fonts goes bigger. but in emulator i see normal behavior. what i have to do? – Fcoder Nov 08 '17 at 19:51
-1

Give fontSize in sp like 20sp, 30sp, then it will automatically adjust font as per the device.

AYUSH ARYA
  • 123
  • 8
  • i dont understand. in xhdpi i have to set 20sp and in xxhdpi 30sp? this way? as i say, if i set 20sp in both, fonts goes 3 times bigger in samsung A5... if i set 30sp then it goes very bigger... this is my problem... in emulator it goes small but in samsung A5 goes bigger – Fcoder Nov 08 '17 at 19:29