I have a simple ListActivity implementation which has the following design
+------+------------------------------------+
| Z1 | Z2 |
| | |
+------+------------------------------------+
being Z1 an ImageView element and Z2 a TextView element. This is my markup
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView android:id="@+id/icon" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:src="@drawable/icon" />
<TextView android:id="@+id/sectionTitle" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:textStyle="bold" />
</LinearLayout>
How do I change my markup to obtain a design that adds one further element like in the following sample?
+------+------------------------------------+
| Z1 | Z2 |
+ +------------------------------------+
| | Z3 (New TextView) |
| | |
+------+------------------------------------+
The best option would be changing your layout into a relative layout.
Make Z1 align parent left
top and bottom and specify its gravity to center,and center vertically (within parent).Z2 should be on the left of Z1 and aligned to parent’s top.
Z3 should be left aligned with Z2 and below Z2.
All these “rules” I used are specified in relative layout.
More info: RelativeLayout documentation and sample tutorial.