The key is a Textview with singleline=false
(which yes is deprecated, but is a must have to work) combined with lines
, maxlines
or minlines
<TextView
android:id="@+id/txtBowlers"
style="@style/Default_TextBox.Small"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:singleLine="false"
android:maxLines="6"
android:text="Bob\nSally\nJohn"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="@+id/txtTeamName"
app:layout_constraintTop_toBottomOf="@+id/txtTeamName"/>
If the text you're putting in the TextView
is short, it will not automatically expand to four lines. If you want the TextView
to always have four lines regardless of the length of the text in it, set the android:lines
attribute:
<TextView
android:id="@+id/address1"
android:gravity="left"
android:layout_height="fill_parent"
android:layout_width="wrap_content"
android:maxLines="4"
android:lines="4"
android:text="Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat."></TextView>
You can do this with TableRow, see below code
<TableRow >
<TextView
android:id="@+id/tv_description_heading"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="left"
android:padding="8dp"
android:text="@string/rating_review"
android:textColor="@color/black"
android:textStyle="bold" />
<TextView
android:id="@+id/tv_description"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="left"
android:maxLines="4"`enter code here`
android:padding="8dp"
android:text="The food test was very good."
android:textColor="@color/black"
android:textColorHint="@color/hint_text_color" />
</TableRow>
Just add textview in ScrollView
<ScrollView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:layout_marginTop="20dp"
android:fillViewport="true">
<TextView
android:id="@+id/txtquestion"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:background="@drawable/abs__dialog_full_holo_light"
android:lines="20"
android:scrollHorizontally="false"
android:scrollbars="vertical"
android:textSize="15sp" />
</ScrollView>
What I learned was to add "\n" in between the words where you want it to brake into the next line. For example...
<TextView
android:id="@+id/time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAlignment="center"
android:text="M-F 9am-5pm \n By Appointment Only" />
The \n between 5pm and By allowed me more control of where I wanted my my next line to begin and end.
I hope these answers are little bit old, just change the input type in resource layout file will solve your problem. For example:
<EditText
android:id="@+id/notesInput"
android:hint="Notes"
android:inputType="textMultiLine"
/>
I used:
TableLayout tablelayout = (TableLayout) view.findViewById(R.id.table);
tablelayout.setColumnShrinkable(1,true);
it worked for me. 1 is the number of column.