2012-01-03 83 views
1

我在我的應用程序的某個活動中運行了幾個圖像瀏覽和一個listview。顯示器在模擬器中看起來很完美,它基本上顯示了一個簡短的字符串,頂部有兩個小圖像,然後是由listview組成的屏幕的其餘部分,但是當我將它放在我的設備(EVO3D)上時,listview被截斷。實際上寬度甚至看起來略微偏離。Android應用程序的高度/寬度在模擬器中不同於設備

這裏是layout.xml文件;

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout 
xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="fill_parent" 
android:layout_height="wrap_content" 
android:orientation="vertical"> 

<TextView android:text="@string/showRunList_name" 
android:layout_width="wrap_content" 
android:layout_height="wrap_content" 
android:id="@+id/editText1"> 
</TextView> 

<ImageView android:contentDescription="@string/auxLogo" 
android:id="@+id/imageView1" 
android:layout_height="wrap_content" 
android:src="@drawable/logo_small" 
android:layout_width="wrap_content" 
android:layout_gravity="center"> 
</ImageView> 

<ImageView android:contentDescription="@string/auxPhone" 
android:id="@+id/imageView2" android:layout_height="wrap_content" 
android:src="@drawable/phone" android:layout_width="wrap_content"> 
</ImageView> 

<TextView 
android:id="@+id/android:empty" 
android:layout_width="wrap_content" 
android:layout_height="wrap_content" 
android:text="@string/main_no_items"/> 

<ListView 
android:id="@+id/android:list" 
android:layout_width="fill_parent" 
android:layout_height="wrap_content" 
android:gravity="bottom|right" 
/> 
</LinearLayout> 

回答

0

檢查這個http://developer.android.com/guide/practices/screens_support.html

創建具有相同的分辨率爲您的設備模擬器和測試。

+0

謝謝,我今天看了這篇文章。我還創建了一個540x960 @ 256dpi的模擬器。我已經能夠在這個新的AVD中複製這個問題,並且努力嘗試讓它以我想要的方式顯示。值得一提的是,我的主要活動不僅僅是我上面列出的那個。 – Shawn 2012-01-04 01:21:47

+0

好的,我明白了我的定義。我的清單文件中的SDK; 感謝您的協助! – Shawn 2012-01-04 01:42:42

0

如果您想支持多屏幕,您需要將多屏幕支持屬性添加到配置文件中,並根據標準創建不同的圖像。看一看here

0

模擬器的分辨率/方面與設備不同。 EVO3D的分辨率爲540x960。您的仿真器可能是HVGA(320x480)或WVGA(480x800)。這種輕微的變化會導致佈局的可見部分發生一些變化。

請記住,您的應用程序在市場上會遇到更多的設備分辨率/寬高比差異,因此它應該對這些更改做出適當的反應。

HTH

1

讓我列出幾點需要照顧過:

  1. 您需要閱讀這篇文章:Supporting Multiple Screens
  2. 正如您所描述的,圖像視圖位於頂部,其餘部分由ListView覆蓋,但是您已在父級中定義了android:layout_height =「wrap_content」,而應該是android:layout_height =「fill_parent」它將具有全屏幕高度。
  3. 要使ListView覆蓋屏幕的其餘部分,請定義android:layout_height="match_parent"android:layout_weight="1"
  4. 使用dpdip代替固定尺寸PX的用於定義像高度/寬度測量。
  5. 使用sp(定標點),同時定義字體大小。
+0

謝謝,我試過了,它仍然在我的設備上顯示相同的方式。我創建了多個仿真器,它們看起來很好,但我的設備似乎正在切斷頁面的整個底部1/3。在我的其他活動中也是如此。 – Shawn 2012-01-04 01:15:51

+0

給我一個佈局的粗略草圖。 – 2012-01-04 05:49:30

相關問題