Created
May 30, 2013 19:34
-
-
Save anonymous/5680487 to your computer and use it in GitHub Desktop.
Set's the first line of a textview to bold.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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