I have a RelativeLayout which has a LinearLayout as a child containing TextViews.
I would like to place ImageViews at the right side of the TextViews with layout_alignRight=”@id/userdetail_tv_special” but somehow this is not working.
Can’t I “link” a child of a RelativeLayout to a child of a LinearLayout? Any ideas how i could achieve this without creating another RelativeLayout for each Button?
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:id="@+id/userdetail_lin_btncontainer"
android:layout_width="fill_parent"
android:layout_height="50dp"
android:layout_below="@id/userdetail_lin_divider"
android:padding="6dp" >
<TextView
android:id="@+id/userdetail_tv_special"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:text="Special"
android:background="#cccccc" />
<!-- here are more TextViews like this one -->
</LinearLayout>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignRight="@id/userdetail_tv_special"
android:src="@drawable/ic_detail_special" />
<!-- much more views and stuff -->
</RelativeLayout>
It would seem logical to me that you cannot point to a “layour” deeper: you can layout the children of a RelativeLayout against each-other, but you LinearLayout is a complete view that you can use as a reference.
If you want to be able to position views relative to the textview, place them as direct children of the relativelayout. I do not see why you would need a LinearLayout here by the way.