Skip to content

Instantly share code, notes, and snippets.

@sourcerebels
Forked from anonymous/snippet.java
Created May 30, 2013 20:31
Show Gist options
  • Save sourcerebels/5680935 to your computer and use it in GitHub Desktop.
Save sourcerebels/5680935 to your computer and use it in GitHub Desktop.
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();
}
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