Android: Layout With Row Span
I am trying to figure out how to create a layout that looks like this. -------------------------------- Sep Text here -------------------------------- text 1 here |
Solution 1:
This can be easily accomplished with a RelativeLayout. It would be implemented in the lines of the following:
<RelativeLayoutandroid:layout_width="fill_parent"android:layout_height="wrap_content"><TextViewandroid:id="@+id/header"android:layout_width="fill_parent"android:layout_height="wrap_content"><ImageViewandroid:id="@+id/img"android:src="@drawable/my_image"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_below="@+id/header"android:layout_alignParentRight="true" /><TextViewandroid:id="@+id/text1"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_below="@+id/header"android:layout_alignParentLeft="true" /><TextViewandroid:id="@+id/text2"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_below="@+id/text1"android:layout_alignParentLeft="true" /></RelativeLayout>
Accessing text1 and text2 by code could be done by:
TextViewtext1= (TextView) findViewById(R.id.text1);
TextViewtext2= (TextView) findViewById(R.id.text2);
// set text
text1.setText("foo");
text2.setText("bar");
Hope it helps!
Post a Comment for "Android: Layout With Row Span"