Created
September 29, 2025 17:06
-
-
Save martarodriguezm/e87d3df71f1c1e0483010c4507755b52 to your computer and use it in GitHub Desktop.
Revisions
-
martarodriguezm created this gist
Sep 29, 2025 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,100 @@ <?xml version="1.0" encoding="utf-8"?> <androidx.constraintlayout.widget.ConstraintLayout 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:padding="16dp"> <!-- Título arriba centrado --> <TextView android:id="@+id/tvTitle" android:layout_width="0dp" android:layout_height="wrap_content" android:text="Ejemplo ConstraintLayout" android:textSize="20sp" android:textStyle="bold" android:gravity="center" app:layout_constraintTop_toTopOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintEnd_toEndOf="parent"/> <EditText android:id="@+id/etName" android:layout_width="wrap_content" android:layout_height="wrap_content" android:hint="Nombre" app:layout_constraintTop_toBottomOf="@id/tvTitle" app:layout_constraintStart_toStartOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintHorizontal_bias="0.7" android:layout_marginEnd="8dp"/> <EditText android:id="@+id/etSurname" android:layout_width="wrap_content" android:layout_height="wrap_content" android:hint="Apellido" app:layout_constraintTop_toBottomOf="@id/etName" app:layout_constraintStart_toStartOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintHorizontal_bias="0.1" android:layout_marginStart="8dp"/> <!-- Spread inside --> <Button android:id="@+id/btn1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Uno" android:layout_margin="5dp" app:layout_constraintTop_toBottomOf="@id/etSurname" app:layout_constraintStart_toStartOf="parent" app:layout_constraintEnd_toStartOf="@id/btn2" app:layout_constraintHorizontal_chainStyle="spread_inside"/> <Button android:id="@+id/btn2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Dos" android:layout_margin="5dp" app:layout_constraintTop_toBottomOf="@id/etSurname" app:layout_constraintStart_toEndOf="@id/btn1" app:layout_constraintEnd_toStartOf="@id/btn3"/> <Button android:id="@+id/btn3" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Tres" android:layout_margin="5dp" app:layout_constraintTop_toBottomOf="@id/etSurname" app:layout_constraintStart_toEndOf="@id/btn2" app:layout_constraintEnd_toEndOf="parent"/> <!-- Botones al fondo --> <Button android:id="@+id/btnOk" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_margin="5dp" android:text="Aceptar" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintEnd_toStartOf="@id/btnCancel" app:layout_constraintHorizontal_weight="1" app:layout_constraintHorizontal_chainStyle="spread"/> <Button android:id="@+id/btnCancel" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_margin="5dp" android:text="Cancelar" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintStart_toEndOf="@id/btnOk" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintHorizontal_weight="1"/> </androidx.constraintlayout.widget.ConstraintLayout> This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,34 @@ <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <!-- Background --> <View android:layout_width="match_parent" android:layout_height="100dp" android:background="@android:color/holo_red_light"/> <!-- Márgenes --> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Click" android:layout_margin="16dp"/> <!-- Padding --> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Hola" android:background="@android:color/holo_red_dark" android:padding="10dp"/> <!-- Visibility --> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Secreto" android:visibility="gone"/> </LinearLayout> This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,60 @@ <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" android:padding="16dp"> <!-- Título ocupa espacio normal --> <TextView android:id="@+id/tvTitle" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="Ejemplo Linear Layout" android:textSize="20sp" android:textStyle="bold" android:gravity="center" android:layout_marginBottom="16dp"/> <!-- Campo de texto ocupa 1 parte --> <EditText android:id="@+id/etName" android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1" android:hint="Escribe tu nombre"/> <!-- Otro campo ocupa 2 partes --> <EditText android:id="@+id/etSurname" android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="2" android:hint="Escribe tu apellido"/> <!-- Botones abajo --> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" android:gravity="center" android:layout_marginTop="16dp"> <Button android:id="@+id/btnOk" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:layout_margin="5dp" android:text="Aceptar"/> <Button android:id="@+id/btnCancel" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:layout_margin="5dp" android:text="Cancelar"/> </LinearLayout> </LinearLayout> This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,60 @@ <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:padding="16dp"> <!-- Título arriba centrado --> <TextView android:id="@+id/tvTitle" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="Ejemplo RelativeLayout" android:textSize="20sp" android:textStyle="bold" android:gravity="center"/> <!-- Campo de nombre debajo del título --> <EditText android:id="@+id/etName" android:layout_width="match_parent" android:layout_height="wrap_content" android:hint="Escribe tu nombre" android:layout_below="@id/tvTitle" android:layout_marginTop="12dp"/> <!-- Campo de apellido debajo del nombre --> <EditText android:id="@+id/etSurname" android:layout_width="match_parent" android:layout_height="wrap_content" android:hint="Escribe tu apellido" android:layout_below="@id/etName" android:layout_marginTop="12dp"/> <!-- Botones abajo centrados --> <LinearLayout android:id="@+id/buttonContainer" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" android:gravity="center" android:layout_alignParentBottom="true" android:layout_marginBottom="16dp"> <Button android:id="@+id/btnOk" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Aceptar" android:layout_marginEnd="8dp"/> <Button android:id="@+id/btnCancel" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Cancelar"/> </LinearLayout> </RelativeLayout>