2012-02-09 85 views
1

我有一個佈局,其中主佈局內有一個相對佈局。此佈局顯示在主佈局的中心。在某些設備中它覆蓋了大部分(有一些部件在它上面和下面)。我測試了它與不同的模擬器。在一些模擬器中,它不覆蓋太多。我希望它應該覆蓋每個屏幕中的相同部分(即在每個模擬器中)。我可以使用佈局:重量?更好的主意?如何使視圖覆蓋儘管不同屏幕的屏幕

<LinearLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    style="@style/ViewScreenTheme" 
    android:orientation="vertical" 
    android:background="@drawable/background" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent"> 

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="vertical" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent"> 
    <RelativeLayout android:id="@+id/header" 
    android:orientation="horizontal" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:gravity="center_horizontal" 
    android:paddingTop="10dp" 
    android:paddingBottom="10dp"> 

    <Button android:id="@+id/help_button" 
     android:layout_alignParentRight="true" 
     style="@style/ButtonText" 
     android:layout_margin="1dp" 
     android:layout_height="wrap_content" 
     android:layout_width="wrap_content" 
     android:background="@drawable/help_button" 
     android:paddingLeft="10px" 
     android:paddingRight="10px" 
     android:layout_marginRight="10px"/> 
    </RelativeLayout> 
    <RelativeLayout android:id="@+id/root" 
    android:orientation="horizontal" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:gravity="center_horizontal" 
    android:layout_below="@+id/header" 
    android:layout_marginTop="2dp" 
    android:layout_marginBottom="0dp" 
    android:paddingTop="10dp" 
    android:paddingBottom="10dp"> 
    <RelativeLayout 
     android:orientation="vertical" 
     android:layout_width="fill_parent" 
     android:layout_height="384dp" 
     android:background="#0fff" 
     android:id="@+id/canvas_layout"> 
    </RelativeLayout> 
    </RelativeLayout> 
</RelativeLayout> 
</LinearLayout> 

我想要canvas_layout這是最後一個相對佈局,以覆蓋每個屏幕中的某個部分。

+1

提供您的xml文件的代碼pls – Jin35 2012-02-09 11:05:45

+0

您必須發佈您的佈局XML文件,否則很難提供幫助。 – 2012-02-09 11:05:59

+0

我添加了xml文件的傢伙,請檢查它。 – 2012-02-09 11:11:51

回答

0

在我看來,處理屏幕尺寸的最佳方法是(如果我正確理解您的問題)是使用資源限定符來提供資源。你可以找到一些指導here

然後,您必須爲您需要的尺寸指定varoius佈局。