J'ai un LinearLayout
horizontal et un EditText
center_horizontal et tout est ok mais quand j'essaye d'ajouter un TextView
à son côté gauche (de l'EditText) le EditText
se déplace vers la droite car les deux contrôles TextView
et EditText
sont centrés. Mon problème est que je veux que le EditText
reste au centre et le TextView
à sa gauche sans déplacer la position centrale de l'EditText. ceci est mon code sans le TextViewImpossible de mettre en œuvre lorsque vous essayez de centrer horizontal edittext dans linearlayout et ajouter un textview sur son côté gauche
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/txtTituloFechaAgenda"
android:orientation="horizontal"
android:weightSum="2"
android:id="@+id/ll1agenda"
android:background="@color/azul"
android:gravity="center_horizontal"
>
<EditText
android:inputType="date"
android:ems="10"
android:layout_alignParentTop="true"
android:id="@+id/etFechaAgenda"
style="@style/textoETFecha"
android:background="@drawable/style_edit_text1"
android:layout_height="37dp"
android:gravity="center_horizontal"
android:layout_width="150dp" />
</LinearLayout>
jusqu'à là le EditText est centré ok. suivant j'ai ajouté le TextView:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/txtTituloFechaAgenda"
android:orientation="horizontal"
android:weightSum="2"
android:id="@+id/ll1agenda"
android:background="@color/azul"
android:gravity="center_horizontal"
>
<TextView
android:text="Fecha: "
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/linearLayout"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
style="@style/textoTitulosBlanco"
android:id="@+id/txtFechaAgenda" />
<EditText
android:inputType="date"
android:ems="10"
android:layout_alignParentTop="true"
android:id="@+id/etFechaAgenda"
style="@style/textoETFecha"
android:background="@drawable/style_edit_text1"
android:layout_height="37dp"
android:gravity="center_horizontal"
android:layout_width="150dp" />
</LinearLayout>
quand je l'ajoute TextView les deux éléments sont centrés et mes EditText se déplace vers la droite et perdre la position centrale. J'espère que vous pouvez m'aider. merci d'avance ...
Oui, j'utilise ce trik, mais cela doit être correct. merci im en utilisant votre solution pour le moment – matQ