Question

guys... i have developed my first app... i have tested this, in Galaxy SIII, it's work fine... but if i run my application in a Galaxy SII the TextView is big...

XML layout:

<TextView
        android:id="@+id/tv3"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignBaseline="@+id/tv4"
        android:layout_alignBottom="@+id/tv4"
        android:layout_alignLeft="@+id/tv2"
        android:layout_marginLeft="23dp"
        android:text="@string/my"
        android:textSize="15dp" />

How do I adjust the resolution automatically with all the screens? What is the easiest choice? I'm confised :| Thank you!!!

Was it helpful?

Solution

Try using sp units instead of dp units for the text, as follows:

android:textSize="15sp"  

From the Documentation:

A dp is a density-independent pixel that corresponds to the physical size of a pixel at 160 dpi. An sp is the same base unit, but is scaled by the user's preferred text size (it’s a scale-independent pixel), so you should use this measurement unit when defining text size (but never for layout sizes).

Also, you can find the differences between these units on Difference between px, dp, dip and sp in Android?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top