- Echemos un vistazo al informe de error de dependencia circular de RelativeLayout.
El código del archivo de diseño de excepción es el siguiente
<?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">
<View
android:id="@+id/v1"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_toLeftOf="@id/v2"
android:background="#ff0000" />
<View
android:id="@+id/v2"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_toRightOf="@id/v1"
android:background="#0000ff" />
</RelativeLayout>
La misma situación de diseño es normal en ConstraintLayout.
<?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">
<View
android:id="@+id/v1"
android:layout_width="50dp"
android:layout_height="50dp"
android:background="#ff0000"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toLeftOf="@id/v2"
app:layout_constraintTop_toTopOf="parent" />
<View
android:id="@+id/v2"
android:layout_width="50dp"
android:layout_height="50dp"
android:background="#0000ff"
app:layout_constraintLeft_toRightOf="@id/v1"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
Como se muestra abajo: