2012-07-31 88 views
-1

我正在開發一個android應用程序。任何人都可以告訴我或發送任何關於文本在android中顯示的鏈接。就圖像而言,我們可以在dp中指定大小以保持大小不變​​。如何爲android做到這一點,以便它可以跨設備讀取?如何在android中顯示文本?

+0

whathaveyoutried.com ?? – 2012-07-31 12:31:49

回答

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

您使用SP單元指定的文本大小。

同樣,你應該更喜歡的SP(規模無關的像素),以 定義文本大小。 sp比例因子取決於用戶設置,並且系統將尺寸與dp相同。

參考的Android文檔上Supporting Multiple Screens

+0

如果使用'wrap_content',選擇什麼尺寸? – 2012-07-31 13:30:58

+0

sp僅用於字體大小。如果在TextView上使用wrap_content,那麼TextView將只與文本一樣大,您設置的字體大小以SP – 2012-07-31 15:28:32

+0

爲單位,但如果我沒有設置任何字體大小,那麼默認的 – 2012-07-31 17:35:36