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 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?
EditText
instead and disable any type of input. – Si8TextView
can be as easy as building aSpannable
out of the individual pieces and applying twoTypefaceSpan
s. – MH.TypeSpans
and reducing further googling. e.g. stackoverflow.com/questions/6612316/… – johnkarka