Android XML de Mise en page pour tous les Appareils (Petite/Normale/Large/XLarge, etc)

Je veux créer un XML de Mise en page qui sera en charge toutes les tailles d'Écran. Dans le XML, le premier élément est ImageView, la deuxième est TextView et le troisième est Button avec une Image. Ainsi, le TextView devrait être la position exacte de tous les périphériques (small, medium, large, xLarge, etc).

Comment puis-je faire cela?

Voici le XML de sortie devrait ressembler à:

Android XML de Mise en page pour tous les Appareils (Petite/Normale/Large/XLarge, etc)

Voici le fichier XML que j'ai créé pour le mode Normal/Moyen de Mise en page:

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

<ImageView
    android:id="@+id/imageView1"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_alignParentTop="true"
    android:src="@drawable/firstscreenimage" />

<RelativeLayout
    android:id="@+id/relativeLayout2"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_alignParentLeft="true" >

    <EditText
        android:id="@+id/campa"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_toRightOf="@+id/textView3"
        android:ems="10" >

        <requestFocus />
    </EditText>

    <TextView
        android:id="@+id/textView3"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        android:gravity="center"
        android:text="My Current\n Campaign" />
</RelativeLayout>

<RelativeLayout
    android:id="@+id/relativeLayout1"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_above="@+id/relativeLayout2"
    android:layout_alignParentLeft="true" >

    <Button
        android:id="@+id/button1"
        android:layout_width="210dp"
        android:layout_height="210dp"
        android:layout_centerHorizontal="true"
        android:layout_centerVertical="true"
        android:background="@drawable/animation0" />

    <TextView
        android:id="@+id/textView2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignBaseline="@+id/button1"
        android:layout_alignBottom="@+id/button1"
        android:layout_centerHorizontal="true"
        android:gravity="center"
        android:text="Start" />
</RelativeLayout>

<TextView
    android:id="@+id/textView1"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_above="@+id/relativeLayout1"
    android:layout_alignParentLeft="true"
    android:layout_marginBottom="42dp"
    android:gravity="right"
    android:paddingRight="25dp"
    android:text="0.0km"
    android:textSize="30dp" />

</RelativeLayout>

OriginalL'auteur Mohammad Rajob | 2014-01-26