2

I use sp for my TextView font size
But the size in mobiles and tablets is similar

My xml :

<TextView
            android:id="@+id/TextView13"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Register"
            android:textColor="#fff"
            android:textSize="14sp" />

Output :

enter image description here

What I want :

enter image description here

Mohammad
  • 111
  • 2
  • 13

2 Answers2

1

You should save different layout for different sizes in drawable files.
In each folder you have separate xml file.
In each xml you can define differentandroid:textSize.

For example, in:

  • drawable-hdpi folder: android:textSize = "10sp"

  • drawable-ldpi folder: android:textSize = "12sp"

  • drawable-mdpi folder: android:textSize = "14sp"

  • drawable-xhdpi folder: android:textSize = "16sp"

  • drawable-xxhdpi folder: android:textSize = "18sp"

1

you can use different qualifiers for each xml or values file.

ie, if you want same design with different styles,you can use 2 styles.xml files with different qualifiers.for eg styles.xml and styles-sw600dp.xml this creates a general style and a 7" tablet style. here sw600dp denotes smallest width as 600dp which is typically used in 7" tabs.

You can get a detailed overview of Multiple Screens in the Android documentation.

you can also define different layouts with the help of qualifiers

Habel Philip
  • 205
  • 3
  • 10