Reputation: 21
I'm trying to use a RelativeLayout to display an image on the left side, and 3 text views, one below another, to the right of the image. Similar is explained here: http://android-developers.blogspot.com/2009/02/android-layout-tricks-1.html. The problem I'm having is that the 3rd text view does not display.
My code:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="?android:attr/listPreferredItemHeight"
android:padding="2dip">
<ImageView android:layout_width="96dip"
android:layout_height="96dip" android:layout_alignParentTop="true"
android:layout_alignParentBottom="true" android:layout_marginRight="2dip"
android:id="@+id/myIcon" android:src="@drawable/icon" />
<TextView android:id="@+id/Line1" android:layout_width="fill_parent"
android:layout_height="30dip" android:layout_toRightOf="@id/myIcon"
android:layout_alignParentRight="true" android:text="Line 1" />
<TextView android:layout_width="fill_parent"
android:layout_height="30dip" android:layout_toRightOf="@id/myIcon"
android:layout_below="@id/Line1"
android:text="Line 2" android:id="@+id/Line2" />
<TextView android:layout_width="fill_parent"
android:layout_height="30dip" android:layout_toRightOf="@id/myIcon"
android:layout_below="@id/Line2"
android:id="@+id/Line3" android:text="Line 3" />
</RelativeLayout>
It's probably something really simple or obvious that I'm either doing wrong or forgetting to do, but I could really use a fresh pair of eyes taking a glance at this. Thanks!
Upvotes: 2
Views: 2292
Reputation: 4955
Try adding
android:layout_alignParentTop="true"
to your Line1 TextView. I'm not sure if this will fix your issue, but it's something to try.
Also, in regard to the '+' sign for IDs: These are for your id declarations. So, in all of your elements, you would have something like this:
android:id="@+id/SomeId"
Which is what you have. However, you do not need them for reference purposes. So
android:layout_below="@id/SomeId"
would be correct. Think of the '+' as declaring an ID and for referencing it, you do not need it.
Also: Try placing some background colors behind your views to make sure they are showing up how you expect them to. That's a debug tip that I use constantly.
Upvotes: 1