文本在android中是如何显示的?

文本在android中是如何显示的?,android,text,Android,Text,我正在开发一个android应用程序。有人能告诉我或发送任何关于android中文本显示方式的链接吗。就图像而言,我们可以在dp中指定大小以保持大小不变。如何为安卓系统做到这一点,使其在设备间保持可读性? <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width=

我正在开发一个android应用程序。有人能告诉我或发送任何关于android中文本显示方式的链接吗。就图像而言,我们可以在dp中指定大小以保持大小不变。如何为安卓系统做到这一点,使其在设备间保持可读性?


<?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>

您可以使用SP单位指定文本大小

类似地,您应该更喜欢sp(缩放独立像素)而不是 定义文本大小。sp比例因数取决于用户设置和 系统缩放大小与dp相同


如果使用了
wrap\u content
,请参阅上的Android文档,选择的大小是多少?sp仅用于字体大小。如果在TextView上使用wrap_内容,则TextView将仅与文本一样大,即您以SPU为单位设置的字体大小,但如果我未设置任何字体大小,则默认值是多少,推荐的sp是多少,以便文本可读