• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Android Textview multiline example

TextView is used to display text on Android application. By default, TextView displays text on one line and if long, TextView will automatically display with more lines to display its text in the most logical way.
Android developers can create a new line on TextView both in programming and syntax. Android developers can create multiline TextView without dividing text into multiple lines according to android: minLines properties.
The following android example code shows us the TextView utility with the xml layout file and the string resource file.
Create layout.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:eek:rientation="vertical">
<TextView
android:id="@+id/text_view1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="30sp"
android:background="#DA70D6"
android:text="This is line 1 \nThis is line 2 \nLine number 3"
/>

<TextView
android:id="@+id/text_view2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="30sp"
android:background="#DEB887"
android:text="This is line 1 \nThis is line 2 \nLine number 3"
android:maxLines="2"
/>

<TextView
android:id="@+id/text_view3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="30sp"
android:background="#8FBC8F"
android:text="This is line 1 \nThis is line 2"
android:minLines="3"
/>

<TextView
android:id="@+id/text_view4"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="30sp"
android:background="#5F9EA0"
android:text="@String/Multiline_Text_By_N"
/>
</LinearLayout>
 

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones