How to achieve automatic line wrapping in Android TextV…

By default, TextView in Android supports automatic line breaks. Simply set the android:singleLine attribute of TextView to false to enable this feature.

In the XML layout file:

<TextView
    android:id="@+id/textView"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="This is a long text that will automatically wrap to the next line"
    android:singleLine="false"/>

In the code:

TextView textView = findViewById(R.id.textView);
textView.setText("This is a long text that will automatically wrap to the next line");
textView.setSingleLine(false);

This way, automatic line wrapping for TextView can be achieved.

bannerAds