TextView textView = new TextView(context); textView.setSingleLine(true);
TextView textView = new TextView(context); textView.setSingleLine(true); textView.setMaxEms(10);This code sets the TextView to a single line mode and restricts the maximum number of characters in a line to 10. Package Library: android.widget.