So my requirement is as follows:
I've multiple strings stored in different string variables, lot of them are hardcore string, some of them are user inputs, while some are values from database(online as well as offline database.)
I want to combine all the strings in single String variable but I want each letter formatted differently as shown in following image.
where as my normal string would be like this:
MAIN TITLE SUBTITLE: Detail 1 Detail 2 Heading 1: User Input Data Heading 2: User Input Data.
Spannable String is your solution.
Here is an example:
final SpannableString text = new SpannableString("Hello World"); text.setSpan(new RelativeSizeSpan(1.5f), text.length() - "World".length(),text.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); text.setSpan(new ForegroundColorSpan(Color.BLACK), 4, text.length() - 4, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); tv.setText(text);