我很努力地完成我的Android應用程序,但我在使用用戶界面時遇到了一些問題。我的問題是非常基本的,在Eclipse中使用AVD管理器(HVGA,密度爲160 dpi)時,我開發了使用默認AVD的UI,當我執行應用程序時,按照我的設計看到它,但是如果我更改目標設備(即WVGA或QVGA)佈局中的所有組件位於與原始位置不同的位置。據我在支持多屏幕的建議中看到,我不應該使用AbsoluteLayouts,實際上我使用RelativeLayouts,我沒有使用尺寸(或位置)的「px」,只是「wrap_content」或「fill_parent 「,如果我需要一個特定的位置,我使用」dp「(也用」sp「進行測試),我也縮放了ldpi(0.75x)的圖像,並且仍然存在問題(不是特定的屏幕,洞應用程序)...所以,我的問題是,是否有任何其他的UI提示,我失蹤?
我把一個示例代碼和我用HVGA AVD(更大圖像)和QVGA AVD進行測試時觀察到的結果。如您所見,黃色/綠色方塊的位置不同,以及最後一排圖像的尺寸也不同。
PS:我也使用TabLayout,所以背景通過代碼加載(tabHost.setBackgroundDrawable(getResources()。getDrawable(R.drawable.background1)))
任何幫助將不勝感激。無法支持多個屏幕分辨率
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:id="@+id/row1"
android:layout_centerHorizontal="true"
android:layout_marginTop="140dp"
>
<ImageView
android:id="@+id/btn1"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:clickable="true"
android:onClick="method1"
android:src="@drawable/button1"
/>
<ImageView
android:id="@+id/btn2"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:clickable="true"
android:onClick="method1"
android:src="@drawable/button2"
/>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_below="@id/row1"
android:layout_centerHorizontal="true"
>
<ImageView
android:id="@+id/btn3"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:clickable="true"
android:onClick="method1"
android:src="@drawable/button3"
/>
<ImageView
android:id="@+id/btn4"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:clickable="true"
android:onClick="method1"
android:src="@drawable/button4"
/>
</LinearLayout>
</RelativeLayout>
添加您的drawables,因爲我不瞭解底部框的大小變化。此外,該白盒不在您的示例佈局中。 – Kaediil
嗨@Kaediil,感謝您的快速響應,白色盒子是背景的一部分,抱歉之前不提。關於drawables,我會盡快添加它們,現在我不知道它是否有幫助,但綠色/黃色框的大小爲mxpi爲50x50,ldpi爲38x38,背景大小爲是240x360(ldpi)和320x480(mdpi)。附加的圖像只是屏幕的一部分。 – maxivis