0

これは私のアプリケーションのメイン アクティビティ画面です。しかし、異なる画面サイズと密度で同じビューを提供していません。助けてください。この問題を解決するにはどうすればよいですか。Android API 10 以降でこの xml レイアウトを使用したいです。ほとんどのテクニックはこの問題を解決しますが、私はしませんでした。

<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>

4

2 に答える 2

0

画面サイズごとに異なる xml ファイルを作成し、それぞれのフォルダーに配置できます。

たとえば、中画面サイズの場合、.xml を res/layout-medium フォルダーに入れます。ラージの場合--- res/layout-large エクストララージの場合---res/layout-xlarge

すべての xml ファイルの名前は、すべてのフォルダーで同じでなければなりません。詳細については、これを読んでください

于 2013-02-19T13:07:02.057 に答える
0

特定の API レベルに対して特定のレイアウトを指定することはできません。マニフェスト ファイルで以下を使用して、最小および最大の API レベルでアプリケーションを実行するように制限できます。

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

特定の画面サイズに特定のレイアウトを使用したい場合は、異なるレイアウト xml ファイルを res/layout-land または res/layout-normal または res/layout-large などに配置することで実行できます。

于 2013-02-19T13:09:12.787 に答える