I have a Relative Layout with 2 columns, and several rows of TextViews. I display a series of long strings in the 2nd column. On high dpi devices, I don't have issues, but on lower dpi devices, the long strings wrap to a 2nd line. This isn't a problem, except it overlaps with the next row.
How do I make the rows automatically resize to the number of lines required?
Here's a snippet of my layout
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/tv_left1"
android:width="100dp"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/tv_right1"
android:layout_alignParentTop="true"
android:layout_toRightOf="@id/tv_left1"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/tv_left2"
android:width="100dp"
android:layout_below="@id/tv_left1"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/tv_right2"
android:layout_alignBaseline="@id/tv_left2"
android:layout_alignBottom="@id/tv_left2"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_toRightOf="@id/tv_left2" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/tv_left3"
android:width="100dp"
android:layout_below="@id/tv_left2"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/tv_right3"
android:layout_alignBaseline="@id/tv_left3"
android:layout_alignBottom="@id/tv_left3"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_toRightOf="@id/tv_left3" />
I have also tried changing my TextView such that the left(n) is to the bottom of right(n-1) rather than right(n), since the left column is fixed while the right column is populated by a variable length string. This looks fine in Android Studio Layout view with intentionally long strings, i.e. the rows start properly below the long strings. It also works properly on a Samsung Galaxy S7 (1440x2560) and Google Pixel (1080x1920). However, when I tried it on a HTC One X (720x1280) and another generic 480x800 device, the row started near the top, overlapping many other rows.
OK, so I ended up using a TableLayout with shrinkColumns="n" where n is the column index (starting from 0) of whatever column I wish to wrap. RelativeLayout does not seem to produce reliable results among older phones.