Reputation: 842
This is my code:
<TableLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true">
<TableRow
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:layout_width="0dp"
android:layout_weight=".50"
android:layout_height="wrap_content"
android:text="Lorem Ipsum is simply dummy text of the printing and typesetting"
android:layout_column="1"/>
<EditText
android:layout_width="0dp"
android:layout_weight=".50"
android:layout_height="wrap_content"
android:id="@+id/editText3" android:layout_column="2"/>
</TableRow>
</TableLayout>
</ScrollView>
In this example there is only 2 lines of text visible but there are more lines than 2. How can I set height of this TextView to wrap content instead of overflowing it?
Upvotes: 1
Views: 1177
Reputation: 2401
Add padding to textview:
android:padding="10dp"
For example:
<TextView
android:layout_width="0dp"
android:layout_weight=".50"
android:layout_height="wrap_content"
android:text="Lorem Ipsum is simply dummy text of the printing and typesetting"
android:layout_column="1"
android:padding="10dp"/>
Upvotes: 2
Reputation: 8869
If you really need a multi line textbox for defined text use
android:singleLine="false"
But it is not good for long text. because sometimes it will overflow your layout. so use scrollable textview is most preferable
android:maxLines = "4"
android:scrollbars = "vertical"
Upvotes: 0
Reputation: 154
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TableLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true">
<TableRow
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Lorem Ipsum is simply dummy text of the printing and typesetting"
android:layout_column="1"/>
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/editText3" android:layout_column="2"/>
</TableRow>
</TableLayout>
Upvotes: 0
Reputation: 8180
You need to add this to the textview
android:inputType="textMultiLine"
android:lines="3"
Upvotes: -1