Skip to main content

Posts

Showing posts from August, 2015

Multiple Styles in a TextView on Android

This is a short snippet on how to have multiple syles in a TextView in Android: tvIntroTwo.setText(R.string. text_introtwo , TextView.BufferType. SPANNABLE ); Spannable spannable = (Spannable) tvIntroTwo.getText(); spannable.setSpan( new TextAppearanceSpan(getApplicationContext(), R.style. TextAppearance_IntroTwo ), 0 , 4 , Spanned. SPAN_EXCLUSIVE_EXCLUSIVE ); In styles.xml: < style name= "TextAppearance_IntroTwo" parent= "TextAppearance.AppCompat.Large" > < item name= "android:textColor" >#f3e740</ item > </ style > As for the text, you can try out a long text, then you'll see the style differences.