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:

StringfirstString="AAAAAA: ";
StringsecondString="BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB";

SpannableStringBuildersb=newSpannableStringBuilder(firstString + secondString);

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

sb.setSpan(newForegroundColorSpan(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 = newTextView(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"