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.
Comments
Post a Comment