2012-02-09 86 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布局。