Try inserting a carriage return and a line where you want to split the text.
These characters refer to old typewriter models. The carriage return was that the cylinder moved back to the start, and the feed line is rolling the cylinder (feed) in one line.
In the calculation, they are represented by two escaped characters (special codes that allow non-printable codes inside a string by prefixing them with a backslash \ ).
- Carriage return is presented
\r - Line feed is represented \
\n (you can remember this as a new line).
For some non-Unix systems (for example, for Windows) for others (for example, for Linux, on which Android is installed) only a new line is required, but it is usually safe to do this everywhere. The only thing that matters is the order in which they are located. It should be \r\n
Put this in your example:
Toast.makeText(context, "First line of text\r\nSecond line of text", Toast.LENGTH_SHORT).show();
On Android, you can only reduce this to the new line character \n , since unix-based systems are not so fussy:
Toast.makeText(context, "First line of text\nSecond line of text", Toast.LENGTH_SHORT).show();
source share