0

How to set the font size for a textview in a phone and a tablet. The posts I've referred suggested to creating dimen.xml and placing them in different folders namely values-mdpi,values-hdpi,values-ldpi . The tablet (1024x600) resolution picks from the values-mdpi folder and so does the the phone (320x480) also picks from the values-mdpi folder, this makes the font look really big and distorted on the phone, whereas it looks fine on the tablet.

Is there any way to specify a font size for the phone and tablet separately.

TNR
  • 5,839
  • 3
  • 33
  • 62
jasdmystery
  • 1,742
  • 1
  • 19
  • 31

4 Answers4

6

For tablets I use:

  • values-sw600dp for 7″
  • values-sw720dp for 10″

This slution can be used not just for localizing dimensions but also other values (for instance, styles).

rciovati
  • 27,603
  • 6
  • 82
  • 101
1

It looks you got misunderstood from references. You should takes values, values-large folders for variation in fonts of Phone and Tablet. And for better results keep using sp units rather than dp for Font Size

TNR
  • 5,839
  • 3
  • 33
  • 62
0

You could just use sp units instead. It is a lot simpler.

Philip Sheard
  • 5,789
  • 5
  • 27
  • 42
0

I tryed this will work text size set default size

create :android/res/values/styles.xml

<style name="Widget.TextView">    
 <item name="android:textAppearance">?android:attr/textAppearanceSmall</item>    
</style>
<style name="TextAppearance.Small">  
<item name="android:textSize">14sp</item>    
<item name="android:textStyle">normal</item>    
<item name="android:textColor">?textColorSecondary</item>    
</style>

where

<item name="textColorSecondary">@android:color/secondary_text_dark</item>

these colors are defined in /res/color/, check /res/color/secondary_text_dark.xml

Satheeshkumar Somu
  • 496
  • 1
  • 7
  • 14