java - Roboto light and Roboto bold in a TextView -
can apply roboto light , roboto bold in same textview on android 2.3 that?
**user** has been publish beez
where **user**
roboto bold , has been publish beez
roboto light
yes can ..
string firstword = "user"; string secondword = "has been publish beez"; // create new spannable 2 strings spannable spannable = new spannablestring(firstword+secondword); // set custom typeface span on section of spannable object spannable.setspan( new customtypefacespan("sans-serif",custom_typeface), 0, firstword.length(), spannable.span_exclusive_exclusive); spannable.setspan( new customtypefacespan("sans-serif-light",second_custom_typeface), firstword.length(), firstword.length() + secondword.length(), spannable.span_exclusive_exclusive); // set text of textview spannable object textview.settext( spannable );
you can use roboto natively android 4.1+ this:
android:fontfamily="sans-serif" // roboto regular android:fontfamily="sans-serif-light" // roboto light android:fontfamily="sans-serif-condensed"
Comments
Post a Comment