androidandroid-relativelayoutdynamic-text

layout_below TextView with dynamic text


I have a RelativeLayout containing two TextViews, the second should be below the first one. The first TextView's text is updated in onCreate() with text conatining newlines which makes it taller, but the second TextView doesn't re-position after this, causing them to overlap. How can I solve this?

<RelativeLayout
        android:id="@+id/layout_parent"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content">

        <TextView
            android:id="@+id/textView_top"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"/>

        <TextView
            android:id="@+id/textView_bottom"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@id/textView_top"/>
</RelativeLayout>

Solution

  • A vertical Linearlayout instead would solve this and also be more efficient.