Java tutorial
//package com.java2s; //License from project: Open Source License import android.text.Spannable; import android.text.SpannableStringBuilder; import android.text.style.AbsoluteSizeSpan; import android.text.style.ForegroundColorSpan; public class Main { public static SpannableStringBuilder getFrontTextStyle(String frontText, String afterText, int frontColor, int frontTextSize) { StringBuilder sb = new StringBuilder(); sb.append("/").append(afterText); int len = sb.length(); sb.insert(0, frontText); SpannableStringBuilder style = new SpannableStringBuilder(sb); style.setSpan(new ForegroundColorSpan(frontColor), 0, sb.length() - len, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); style.setSpan(new AbsoluteSizeSpan(frontTextSize), 0, sb.length() - len, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); return style; } }