방법 1
public static void increaseFontSizeForPath(Spannable spannable, String path, float increaseTime) {
int startIndexOfPath = spannable.toString().indexOf(path);
spannable.setSpan(new RelativeSizeSpan(increaseTime), startIndexOfPath,
startIndexOfPath + path.length(), 0);
}
사용
Utils.increaseFontSizeForPath(spannable, "big", 3); // make "big" text bigger 3 time than normal text
방법 2
public static void setFontSizeForPath(Spannable spannable, String path, int fontSizeInPixel) {
int startIndexOfPath = spannable.toString().indexOf(path);
spannable.setSpan(new AbsoluteSizeSpan(fontSizeInPixel), startIndexOfPath,
startIndexOfPath + path.length(), 0);
}
사용
Utils.setFontSizeForPath(spannable, "big", (int) textView.getTextSize() + 20); // make "big" text bigger 20px than normal text