Alignez le haut de la Vue vers le bas d'un autre point de vue dans un RelativeLayout
Comment puis-je aligner une View
'à l'autre View
's bas? J'ai besoin de deux vues, l'une sur l'autre. J'ai obtenu le droit en position verticale avec un simple android:layout_below="id_of_the_top_view"
, mais je n'arrive pas à aligner les View
s horizontalement. Je voudrais quelque chose comme android:layout_alignTopToBottomOf="id_of_the_top_view"
, ou en général quelque chose qui me permet d'aligner une View
centre (horizontale ou verticale) à l'autre View
centre.
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<!-- center picker @ minutes -->
<NumberPicker
android:id="@+id/npicker_minutes"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp" />
<!-- left picker @ hours -->
<NumberPicker
android:id="@+id/npicker_hours"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toLeftOf="@id/npicker_minutes" />
<!-- right picker @ seconds -->
<NumberPicker
android:id="@+id/npicker_seconds"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toRightOf="@id/npicker_minutes" />
<TextView
android:id="@+id/tv_minutes"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_below="@id/npicker_minutes"
android:layout_marginTop="20dp"
android:paddingBottom="15dp"
android:text="@string/minutes_short" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/npicker_hours"
android:layout_toLeftOf="@id/tv_minutes"
android:layout_marginTop="20dp"
android:paddingBottom="15dp"
android:text="@string/hours_short" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/npicker_seconds"
android:layout_toRightOf="@id/tv_minutes"
android:layout_marginTop="20dp"
android:paddingBottom="15dp"
android:text="@string/seconds_short" />
</RelativeLayout>
Ce que j'ai est ceci:
Et ce que j'ai besoin de réaliser est que les trois TextView
s ("hh", "mm" et "ss"), sont placés chacun en dessous du nombre de cueilleurs, avec le centre horizontal de l' TextView
aligné sur le centre horizontal de l' NumberPicker
.
Je suis désolé, j'ai édité ma question de fournir autant d'informations que j'ai pu. Je vous remercie.
OriginalL'auteur whatyouhide | 2013-03-03
Vous devez vous connecter pour publier un commentaire.
Vous devez ajouter ces lignes à votre TextViews:
Échantillon complet de votre code:
L'alternative est d'utiliser l'arbre LinearLayouts, chaque avec un NumberPicker et un TextView à l'intérieur.
OriginalL'auteur gingo
Vous pouvez utiliser les propriétés suivantes pour aligner le premier et le troisième de la vue du texte:
TextView
s n'est pas aligné avec le centre horizontal de le nombre de cueilleurs. Ils sont alignés avec le côté droit et gauche du nombre de cueilleurs. Je sais que je pourrais utiliser le rembourrage et les marges, mais je tiens à garder ce que beaucoup de portable que je peux.OriginalL'auteur Karan_Rana