2012-11-08 63 views
4

我想知道如何讓應用程序在不同的設備上看起來相同。我多次閱讀Supporting Multiple Screens,但我仍然無法理解如何生活。在不同的設備上使文本大小相同

下面是一個示例佈局:

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
       android:orientation="vertical" 
       android:layout_width="fill_parent" 
       android:layout_height="fill_parent" 
     > 
    <TextView 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:text="Hello World, MyActivity" 
      android:textSize="30sp" 
      /> 
</LinearLayout> 

有銀河S II(480×800)和感覺XE(540x960)。它們都是hdpi,物理屏幕尺寸幾乎相同。我希望看到同樣看好這兩個設備,但實際上在540x960的文字較小然後在480×800: enter image description here (左邊是480×800,右邊是540x960)

我試圖指定文字大小尺寸的資源,使獨立文件夾values-w540dp但它沒有效果。

你們如何讓你的應用在不同的hdpi設備上看起來一樣?使用屏幕的高度和寬度:here.Otherwise你一些比(TEXTSIZE =因子*高度或因子可以生成等)必須設置你的佈局動態地

+0

技術上那些事情2是相等的。它可以使文本具有相同的大小,但不能使較小的屏幕更寬。:)請注意,「Hello」大概在「Demo」結尾的同一位置結束? –

回答

3
android:textAppearance="?android:attr/textAppearanceLarge" 

android:textAppearance="?android:attr/textAppearanceMedium" 

android:textAppearance="?android:attr/textAppearanceSmall" 

這些atributes可以解決問題。

0

看看metrics,如果您在dp(密度獨立像素)中指定文本大小,它應該可以工作。文本的默認大小應該在14dp左右。 (TextAppearance.small)

相關問題