Firstly, I'll tell you that I discourage setting long texts to tab names. Tab titles are intended to give a short and easily understandable descriptions, setting your names to long texts might complicate your users.
Said that, one approach would be defining a new layout where you would implement two separate TextView
s, or just one setting its maxLines
attribute to 2
. This way, you could simply inflate
your tab by doing something like:
final View view = LayoutInflater.from(context).inflate(R.layout.your_new_tab_layout, null);
TextView tv1 = view.findViewById(R.id.your_first_line_textview);
TextView tv2 = view.findViewById(R.id.your_second_line_textview);
tv1.setText("My first line");
tv2.setText("My second line");
Or, using the second approach:
final View view = LayoutInflater.from(context).inflate(R.layout.your_new_tab_layout, null);
TextView tv = view.findViewById(R.id.your_double_line_textview);
tv.setText("First line\nSecond line);