1

my android xml layout file keeps on Exception raised during rendering: Circular dependencies cannot exist in RelativeLayout Exception details are logged in Window > Show View > Error Log I cant figure out why? here is my code

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.amandhapola.ribbit.LoginActivity"
    android:background="@drawable/background_fill" >

     <ImageView
         android:id="@+id/backgroundImage"
         android:layout_width="match_parent"
         android:layout_height="match_parent"
         android:layout_alignParentLeft="true"
         android:layout_alignParentTop="true"
         android:scaleType="fitStart"
         android:src="@drawable/background" 
         android:contentDescription="@string/content_desc_background"/>
       <TextView
        android:id="@+id/title"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_above="@+id/subtitle"
        android:layout_centerHorizontal="true"
        android:textSize="60sp"
        android:layout_marginTop="32dp"
        android:textColor="@android:color/white"
        android:textStyle="bold"
        android:text="@string/app_name" />

     <TextView
        android:id="@+id/subtitle"
        android:layout_centerHorizontal="true"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/title"
        android:layout_above="@+id/usernameField"
        android:textSize="13sp"
        android:textColor="@android:color/white"
        android:textStyle="bold"
        android:text="@string/subtitle"/>

       <EditText
        android:id="@+id/usernameField"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_above="@+id/passwordField"
        android:layout_below="@+id/subtitle"
        android:layout_alignParentLeft="true"
        android:ems="10"
        android:hint="@string/username_hint" />

        <EditText
        android:id="@+id/passwordField"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/usernameField"
        android:layout_above="@+id/loginButton"
        android:layout_alignParentLeft="true"
        android:layout_marginBottom="43dp"
        android:ems="10"
        android:hint="@string/password_hint"
        android:inputType="textPassword" />

        <Button
        android:id="@+id/loginButton"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/passwordField"
        android:layout_above="@+id/signUpText"
        android:layout_alignParentLeft="true"
        android:text="@string/login_button_label" />



    <TextView
        android:id="@+id/signUpText"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
       android:layout_marginTop="12dp"
        android:layout_centerHorizontal="true"
        android:textColor="@android:color/white"
       android:layout_below="@+id/loginButton"
        android:text="@string/sign_up_text" />

</RelativeLayout>
AmanDhapola
  • 47
  • 2
  • 9

1 Answers1

1

You have defined your title to be above your subtitle, and your subtitle to be below your title:

<TextView android:id="@+id/title" ... android:layout_above="@+id/subtitle" ... />
<TextView android:id="@+id/subtitle" ... android:layout_below="@+id/title" ... />

That's a circular reference: To position title, Android first needs to determine the position of subtitle. However, to position subtitle, it needs to determine the position of title first.

You need to make sure that Android can position your elements without getting into a depencendy loop. For example, positioning the title at the top, and then positioning the subtitle below the title would be fine.

Heinzi
  • 167,459
  • 57
  • 363
  • 519