2011-01-31 89 views
1

首先,我在仿真器上運行程序。之後,我運行許多Android手機。有些非常小,有些顯示在旋轉側,然後不能旋轉,並且不能滾動(我沒有這樣做),有些是可以的。如何在Android上處理不同尺寸的屏幕

我的理解可能是由不同類型的屏幕引起的,我使用AbsoluteLayout,但我不知道如何解決這個問題。所以,我需要解決這個問題。任何人都可以幫忙由於KA

示例頁面,我所做的:

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

<TextView 
    android:id="@+id/usrname" 
    android:layout_width="wrap_content" 
    android:layout_height="21px" 
    android:layout_x="105px" 
    android:layout_y="179px" 
    android:text="Username :" 
    android:textSize="18sp" 
    android:textStyle="bold" /> 

<EditText 
    android:id="@+id/usrname_text" 
    android:layout_width="161px" 
    android:layout_height="wrap_content" 
    android:layout_x="74px" 
    android:layout_y="206px" 
    android:textSize="12sp" /> 

<TextView 
    android:id="@+id/pass" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_x="105px" 
    android:layout_y="252px" 
    android:text="Password :" 
    android:textSize="18sp" 
    android:textStyle="bold" > 
</TextView> 

<EditText 
    android:id="@+id/pass_text" 
    android:layout_width="163px" 
    android:layout_height="wrap_content" 
    android:layout_x="73px" 
    android:layout_y="279px" 
    android:password="true" 
    android:textSize="12sp" /> 

<Button 
    android:id="@+id/login" 
    android:layout_width="73px" 
    android:layout_height="wrap_content" 
    android:layout_x="75px" 
    android:layout_y="333px" 
    android:text="Login" /> 

<Button 
    android:id="@+id/cancle" 
    android:layout_width="73px" 
    android:layout_height="wrap_content" 
    android:layout_x="157px" 
    android:layout_y="333px" 
    android:text="Cancel" /> 

</AbsoluteLayout> 

這些是銀河-S圖片和仿真器:

enter image description here enter image description here

回答

3

FO rthis問題u使用支持屏幕標籤在manifest資源配置文件。進一步的參考見下面的鏈接 Support screens

+0

我試過 - > android:anyDensity =「true」,android:normalScreen =「true」,但沒有任何變化。 – Yoo 2011-01-31 08:51:13

3

T他的開發人員文檔在Supporting Multiple Screens上的文章中對此有很多很好的指導。在最佳實踐部分下,他們建議不要使用AbsoluteLayout。如果你分享你正在努力完成的任務,我們可能會提出一種適用於各種屏幕的方法。

+0

我不知道我是否使用絕對佈局,我應該使用哪些其他佈局。 – Yoo 2011-01-31 08:49:27

1

真的認爲你應該看看相對佈局,尤其是如果你現在開始使用android。它有點難度,因爲你無法給出任何物品的絕對座標,但是你可以相互定位物品。之後,你不必擔心abt不同的屏幕尺寸。