Here is the layout:
You can avoid all of this by giving each textview a width of match_parent and an appropriate layout_weight. The below code will give you exactly what you need. Enjoy!
<?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:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="3"
android:text="Test 1"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="line too long line too long line too long line too long line too long "/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="3"
android:text="Test 2"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="line too long line too long line too long line too long line too long "/>
</LinearLayout>
</LinearLayout>
The answer is easy. Just 3 lines of XML code. In your textview, place the following lines:
<TextView
android:layout_width = "match_parent"
android:layout_height = "wrap_content"
android:width = "0dp"/>
This is because your textView width is wrap_content. So means if your text is too long then it will be out of screen. So better way is to set it to match_parent.
And Yes if it is too long then you can set MaxLines for it.