1
votes

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 have both English and Arabic in single text , so how is it possible for me to apply arabic and english font on the same Textview? Is it possible that i merge two fonts in one font type , and apply it every where, will that work?

2
You may look into EditText instead and disable any type of input.Si8
Using two different fonts (or typefaces) in a single TextView can be as easy as building a Spannable out of the individual pieces and applying two TypefaceSpans.MH.
@SiKni8 is it possible to add multiple fonts in a single edittext?chossen-addict
@chossen-addict I added an answer for you. The link is also very helpful :)Si8
@MH Yes you are right but why don't you help others by providing a link to sample usage of TypeSpans and reducing further googling. e.g. stackoverflow.com/questions/6612316/…johnkarka

2 Answers

1
votes

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

0
votes

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?