Skip to content

Instantly share code, notes, and snippets.

Created May 30, 2013 19:34
Show Gist options
  • Save anonymous/5680487 to your computer and use it in GitHub Desktop.
Save anonymous/5680487 to your computer and use it in GitHub Desktop.
Set's the first line of a textview to bold.
public static void setFirstLineBold(TextView tv) {
String txt = tv.getText().toString();
Spannable span = new SpannableString(txt);
int end = txt.indexOf('\n');
if (end == -1) {
end = txt.length() - 1;
}
span.setSpan(new StyleSpan(android.graphics.Typeface.BOLD), 0, end,
Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
tv.setText(span);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment