Java tutorial
//package com.java2s; import android.text.SpannableString; import android.text.Spanned; import android.text.TextUtils; import android.text.style.AbsoluteSizeSpan; public class Main { public static SpannableString setTextSize(String content, int startIndex, int endIndex, int fontSize) { if (TextUtils.isEmpty(content) || fontSize <= 0 || startIndex >= endIndex || startIndex < 0 || endIndex >= content.length()) { return null; } SpannableString spannableString = new SpannableString(content); spannableString.setSpan(new AbsoluteSizeSpan(fontSize), startIndex, endIndex, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); return spannableString; } }