7
votes

Qu'est-ce que Android: Layout_alignleft à Android?

Je ne pouvais pas comprendre l'attribut Android: layout_alignleft. Je suis nouveau dans le développement Android.

<RelativeLayout 
        android:id="@+id/r5"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@id/r4"

        > <TextView
              android:id="@+id/tv3"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_centerHorizontal="true"
              android:layout_centerVertical="true"
              android:layout_marginTop="10dp"
               android:textSize="16sp"
              android:textColor="#663300"
              android:text="TextView"

               />

          <TextView
              android:id="@+id/tv5"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"            
              android:layout_marginTop="10dp"

              android:layout_alignLeft="@id/tv3"
               android:textSize="16sp"
              android:textColor="#663300"
              android:text="TextView"


               />
         <TextView
              android:id="@+id/tv6"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_toRightOf="@id/tv5"
              android:layout_marginTop="10dp"
               android:textSize="16sp"
              android:textColor="#663300"
              android:text="TextView"

               />

          </RelativeLayout>


1 commentaires

Vous devriez probablement lire une autre documentation Android.


5 Réponses :


21
votes

layout_alignleft Le bord gauche de votre vue correspond au bord gauche de la vue dont vous utilisez les paramètres.

Layout_toleftof Fait votre vue sur le côté gauche de la vue dont l'identifiant que vous utilisez (le bord droit sera aligné avec le bord gauche de l'autre vue).


0 commentaires

2
votes

règle d'Align_left qui aligne le bord gauche de l'enfant avec le bord gauche d'un enfant.

Rule de gauche_fr qui aligne le bord droit de l'enfant avec le bord gauche d'un enfant avec le bord gauche d'un enfant. P>

in your above example the align left is used in a way below.

 tv5 textview is align left of the tv3 layout in android.


0 commentaires

0
votes

Android: Layout_Alignleft est destiné, par exemple: vous utilisez une TextView.Le expresse par exemple. Il y a deux

textview.ur premier identifiant de texte comme @ + id / t1. Suivant View Say T2IS @ + ID / T2. Si vous voulez placer

Deuxième TextView à gauche de la première TextView, vous pouvez renvoyer l'ID dans la T2 IE

Android: Layout_leftof = "@ + id / t1"


0 commentaires

1
votes

Les deux paramètres sont utilisés en présentation relative. Parler de Android: Layout_leftof , ce paramètre permet de passer à la vue "à gauche" (non alignée) de la vue dont vous passez comme une valeur.on l'autre Android: Layout_alignleft vous placera de la vue à partir du même point (à partir de gauche dans ce cas) où la vue que vous avez passée, l'ID commence. Aussi int ce cas, votre vue peut chevaucher l'autre vue (comme parfois, il est utilisé pour garder une vue à l'intérieur d'une autre vue)


1 commentaires

Aucun identifiant de ressource trouvé pour attribut 'Layout_Leftof' dans le paquet 'Android'.



1
votes

Android: Layout_alignleft aligne les deux côtés gauche. (PIC 1)

Android: Layout_toleftof aligne une disposition à gauche d'une autre. (PIC 2) P>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#D6D6D6"
    android:orientation="vertical">


    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <LinearLayout
            android:layout_width="400dp"
            android:layout_height="400dp"
            android:layout_alignLeft="@+id/ll1"
            android:background="#00FF00"
            android:orientation="vertical">  </LinearLayout>

            <LinearLayout
                android:id="@+id/ll1"
                android:layout_width="200dp"
                android:layout_alignParentRight="true"
                android:layout_height="200dp"
                android:background="#00FFFF"
                android:orientation="vertical"></LinearLayout>


    </RelativeLayout>


    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="50dp">


        <LinearLayout
            android:layout_width="400dp"
            android:layout_height="400dp"
            android:layout_toLeftOf="@+id/ll2"
            android:background="#00FF00"
            android:orientation="vertical"></LinearLayout>

            <LinearLayout
                android:id="@+id/ll2"
                android:layout_width="200px"
                android:layout_height="200px"
                android:layout_alignParentRight="true"
                android:background="#00FFFF"
                android:orientation="vertical">
        </LinearLayout>

    </RelativeLayout>

</LinearLayout>


0 commentaires