I am developing an android app whose relative layout is given below.
Here is an imgur link to how the app shows on screen: https://i.stack.imgur.com/9oaLz.jpg. I would like ‘Text 1’ to appear right above ‘a lazy fox ..’. Hope that helps clarify what I wish to accomplish.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="wrap_content" android:layout_width="fill_parent"
android:background="@color/white">
<TextView android:id="@+id/text1" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_marginLeft="0dip"
android:textColor="@color/black" android:text="Text 1" android:lines="1"
android:scrollHorizontally="true" android:ellipsize="end" />
<Button android:id="@+id/checkBox" android:layout_height="wrap_content"
android:layout_width="wrap_content" android:drawableRight="@drawable/checkbox_unchecked_30"
android:layout_below="@+id/text1" android:background="@color/white" />
<TextView android:id="@+id/text2" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_toRightOf="@+id/checkBox"
android:layout_alignTop="@+id/checkBox" android:layout_below="@+id/text1"
android:textColor="@color/black" android:text="a lazy fox jumped over the dam and said help"
android:lines="1" android:scrollHorizontally="true" android:ellipsize="end" />
<TextView android:id="@+id/text3" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_toRightOf="@+id/checkBox"
android:layout_below="@+id/text2" android:textColor="@color/black"
android:text="Text 3" />
<TextView android:id="@+id/text4" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_below="@+id/text2"
android:layout_toRightOf="@+id/text3" android:textColor="@color/black"
android:text="Text 4" />
<TextView android:id="@+id/text5" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_below="@+id/text2"
android:layout_toRightOf="@+id/text4" android:textColor="@color/black"
android:text="Text 5" />
</RelativeLayout>
I want “Text 1” to appear right above the text that starts off with “a lazy fox…”. Right now ‘Text 1’ appears above the checkbox. I am not sure how to achieve the above. I have tried various things but nothing seems to be working. What should I be doing to achieve the desired layout?
I was targeting Android 1.5 in which forward references do not work in RelativeLayout. Forward references were first implemented in Android 1.6 (See: http://developer.android.com/resources/articles/ui-1.6.html) and hence any of the suggested solutions by others were not working.