2013-02-19 68 views
0

这是我的应用程序的主要活动屏幕,但我不提供相同的视图在不同的屏幕尺寸和密度。请帮助我。我可以如何解决这个问题。我想用这个XML与Android API 10和更高的布局。我尝试了大多数技术解决这个问题,但我没有。Android 4.0不同的屏幕尺寸和密度

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
android:id="@+id/firstLayout" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:layout_gravity="center" 
android:animateLayoutChanges="true" 
android:background="@drawable/home" 
> 



<RelativeLayout 
    android:id="@+id/topheader" 
    android:layout_width="match_parent" 
    android:layout_height="142dip" 
    android:layout_alignParentLeft="true" 
    android:layout_alignParentTop="true" > 
</RelativeLayout> 

<RelativeLayout 
    android:id="@+id/RelativeLayout1" 
    android:layout_width="wrap_content" 
    android:layout_height="320dip" 
    android:layout_alignParentBottom="true" 
    android:layout_alignParentLeft="true" > 

    <include 
     android:id="@+id/include2" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_above="@+id/include3" 
     android:layout_alignParentLeft="true" 
     android:layout_marginBottom="20dip" 
     layout="@layout/anaekran_seconddock" /> 

    <include 
     android:id="@+id/include1" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_above="@+id/include2" 
     android:layout_alignParentLeft="true" 
     android:layout_marginBottom="20dip" 
     layout="@layout/anaekran_firstdock" /> 

    <include 
     android:id="@+id/include3" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentBottom="true" 
     android:layout_alignParentLeft="true" 
     android:layout_marginBottom="30dip" 
     layout="@layout/anaekran_thirddock" /> 
</RelativeLayout> 

<RelativeLayout 
    android:id="@+id/relativeLayout2" 
    android:layout_width="match_parent" 
    android:layout_height="142dip" 
    android:layout_alignParentLeft="true" 
    android:layout_below="@+id/topheader" 
    android:background="@color/gray" > 

    <Gallery 
     android:id="@+id/gallery1" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" /> 
</RelativeLayout> 

+0

您的意思是说您的布局在包含api 10或更高版本的设备中不可见? – GrIsHu 2013-02-19 12:54:41

回答

0

,您可以创建不同的屏幕尺寸不同的XML文件,并把他们在各自的文件夹中。

例如,对于中等屏幕尺寸,将.xml放在res/layout-medium文件夹中。 for large --- res/layout-large for extralarge --- res/layout-xlarge

所有xml文件的名称在所有文件夹中必须相同。 阅读更多信息this

0

您无法为某个API leverl指定特定布局。你可以限制你的应用程序将使用在您的清单文件中的以下的最小和最大API级别上运行:

<uses-sdk 
    android:minSdkVersion="14" 
    android:targetSdkVersion="17" /> 

,如果你想使用某些屏幕尺寸特殊的布局,你可以做到这一点通过将不同的布局的XML文件在res/layout-land或res/layout-normal或res/layout-large等等。