Code example for UnderlineSpan

0
    } 
 
    private static int format4(String text, int start, StringBuilder sb, List<StyleWithRegion> styles) {
        int end = text.indexOf('\n', start);
        if(end != -1) {
            styles.add(new StyleWithRegion(new UnderlineSpan(), sb.length()+4, sb.length()+end-start));
            styles.add(new StyleWithRegion(new ForegroundColorSpan(Color.CYAN), sb.length()+4, sb.length()+end-start));
            sb.append(text.substring(start,end)+"\n");
        } else { 
            end = start;
        } 
        return end;
    } 
 
    private static int format5(String text, int start, StringBuilder sb, List<StyleWithRegion> styles) {
        int end = text.indexOf('>', start);
        if(end != -1) {
            styles.add(new StyleWithRegion(new StyleSpan(Typeface.BOLD), sb.length(), sb.length()+end-start));
            styles.add(new StyleWithRegion(new ForegroundColorSpan(Color.GREEN), sb.length(), sb.length()+end-start));
            sb.append(text.substring(start,end));
        } else {