class WordBreakTransformationMethod extends ReplacementTransformationMethod { private static WordBreakTransformationMethod instance; private WordBreakTransformationMethod() {} public static WordBreakTransformationMethod getInstance() { if (instance == null) { instance = new WordBreakTransformationMethod(); } return instance; } private static char[] dash = new char[] {'-', '\u2011'}; private static char[] space = new char[] {' ', '\u00A0'}; private static char[] original = new char[] {dash[0], space[0]}; private static char[] replacement = new char[] {dash[1], space[1]}; @Override protected char[] getOriginal() { return original; } @Override protected char[] getReplacement() { return replacement; } }
myEditText.setTransformationMethod(WordBreakTransformationMethod.getInstance());
References
https://stackoverflow.com/questions/22289161/word-wrap-break-word-in-edittext