¿Cómo se muestra el texto en android? [cerrado]

I am developing an android application. Could anybody tell me or send any link about how text is displayed in android. As far as images is concerned, we can specify the size in dp to keep the size constant. How to do this for android so that it remains readable across devices?

preguntado el 31 de julio de 12 a las 13:07

2 Respuestas

You specify your text sizes using the SP unit.

Similarly, you should prefer the sp (scale-independent pixel) to define text sizes. The sp scale factor depends on a user setting and the system scales the size the same as it does for dp.

Refer to Android Docs on Soporta múltiples pantallas

Respondido 31 Jul 12, 13:07

what size is chosen if wrap_content se usa? - John Watson

sp is only used font-size. If you use wrap_content on a TextView, the TextView will only be as big as the text, who's font size you set in units of SP - Zaid Daghestani

but if I do not set any font size , what will be the default - John Watson

also, what is the recommended sp , so that text is readable - John Watson

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="horizontal" >

    <TextView
        android:id="@+id/textViewOrderProduct"
        android:layout_width="wrap_content"
        android:layout_height="45dp"
        android:layout_marginLeft="5dp"
        android:onClick="hideKeyBord"
        android:text="123"
        android:textSize="15dp"
        android:width="100dp" />

    <EditText
        android:id="@+id/editTextOrderQty"
        android:layout_width="wrap_content"
        android:layout_height="45dp"
        android:layout_marginLeft="5dp"
        android:layout_marginTop="8dp"
        android:background="#ffffff"
        android:inputType="number"
        android:maxLength="4"
        android:text="123"
        android:textSize="13dp"
        android:width="50dp" />

    <EditText
        android:id="@+id/editTextOrderprice"
        android:layout_width="wrap_content"
        android:layout_height="45dp"
        android:layout_marginLeft="5dp"
        android:layout_marginTop="8dp"
        android:background="#ffffff"
        android:inputType="number"
        android:maxLength="5"
        android:text="123"
        android:textSize="13dp"
        android:width="50dp" />

    <TextView
        android:id="@+id/textViewOrderStock"
        android:layout_width="wrap_content"
        android:layout_height="45dp"
        android:layout_marginLeft="5dp"
        android:onClick="hideKeyBord"
        android:text="123"
        android:textSize="13dp"
        android:width="50dp" />

</LinearLayout>

Respondido 31 Jul 12, 13:07

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.