Let's say one has a simple series of TextViews
inside LinearLayouts
like the ones below, with text dynamically populating to the respective TextViews
.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="New Text"
android:id="@+id/textView2" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="New Text"
android:id="@+id/textView3" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="New Text"
android:id="@+id/textView4" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="New Text"
android:id="@+id/textView5" />
</LinearLayout>
</LinearLayout>
How could one make it that if the text of 2 TextViews
, let's say textView2
and textView3
, or textView4
and textView5
, are too wide to fit inline, then the orientation of their parent LinearLayout dynamically changes to vertical, to place one above the other instead, so that the text isn't broken off by the end of the screen in an odd way?
Thanks in advance!