Reputation: 24213
I have the below layout right now in my RelativeLayout
<EditText
android:id="@+id/text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_toStartOf="@+id/button"
android:layout_toLeftOf="@id/button"
android:hint="Whatsup!"
android:padding="10dp" />
<ImageView
android:id="@id/button"
android:layout_width="80dp"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_alignParentRight="true"
android:layout_alignBottom="@id/text"
android:layout_alignTop="@id/text"
android:src="@drawable/ic_mic_black_off"
android:layout_alignParentEnd="true" />
This makes my ImageView to be of size 80dp, and the left side of it is filled with EditText.
Now if I add a property "android:layout_toRightOf="@id/text"", then both my views disappear? Why's that?
Upvotes: 0
Views: 42
Reputation: 9073
This is because of circular dependency. Your views are depending on each other to place themselves on the screen.
Your EditText
is already dependent on ImageView
by android:layout_toStartOf="@+id/button"
Now when you add android:layout_toRightOf="@id/text"
your ImageView
depends on EditText
it becomes circular. which is not allowed.
If you look in the studio Just below "Design" tab there will be red exclamation. click on that & you'll see following error.
Upvotes: 1