Skip to content Skip to sidebar Skip to footer

Multiple Font To Single Textview Depending On Langugage

So at the moment I have textviews with English text and Arabic text and I am doing is applying font depending what language is in the textview , but there are some times when i hav

Solution 1:

Found this:

String firstString = "AAAAAA: ";
String secondString = "BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB";

SpannableStringBuilder sb = new SpannableStringBuilder(firstString + secondString);

sb.setSpan(new StyleSpan(android.graphics.Typeface.BOLD), 0, firstString.length(),
        Spannable.SPAN_INCLUSIVE_INCLUSIVE);

sb.setSpan(new ForegroundColorSpan(Color.rgb(255, 0, 0)), firstString.length() + 1,
        firstString.length() + secondString.length(),
        Spannable.SPAN_INCLUSIVE_INCLUSIVE);

textView.setText(sb);

might work


Solution 2:

You can try something like this:

mBox = new TextView(context);
mBox.setText(Html.fromHtml("<b>" + title + "</b>" +  "<br />" + 
            "<small>" + description + "</small>" + "<br />" + 
            "<small>" + DateAdded + "</small>"));

taken from here: Is it possible to have multiple styles inside a TextView?


Post a Comment for "Multiple Font To Single Textview Depending On Langugage"