I think the best solution is to avoid the interrupt string and use a custom view component.
AlertDialog.Builder builder = new AlertDialog.Builder(this); TextView tw =new TextView(this); tw.setMaxLines(10); tw.setPadding(3,3,3,3); tw.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); tw.setSingleLine(false); tw.setText("ver long messagge \n with break line \n"); builder.setView(tw);
With this solution, you can break the line if you want to use \n , but if you do not, the text will be wrapped in several lines (since I set tw.setSingleLine(false); ).
source share