0

I am working with an Android app, which shows some text in Bengali.

This sentence is in the app resources string file:

    <resources>
    <string name="sentence">১৯৭৫ সালে বিল গেটস(Bill Gates) এবং পল এলেন(Paul Allen) একসাথে "মাইক্রোসফট"("MicroSoft") নামক কোম্পানি প্রতিষ্ঠা করেন, যেটা পরবর্তীতে পৃথিবীর সবচেয়ে বড় পিসি কোম্পানির মর্যাদা পায়।</string>"
    </resources>

I want to show this whole sentence in Bengali, so I set typeface to my textview and I can use different Bengali fonts, but the problem is I need to show names (Bill Gates, Paul Allen and Microsoft) in English instead of Bengali font. How can I do it?

DaveyDaveDave
  • 9,821
  • 11
  • 64
  • 77
Bashir Fardoush
  • 184
  • 1
  • 10

1 Answers1

0

You can use HTML commands in your text view and then apply different typefaces to different parts of this TextView.

You can do this:

textView.setText(Html.fromHtml("<font size=... color=... face=...>" + getString(R.string.sentence) + "</font>"))

This would set the typeface of the whole sentence to the defined one. To do this only on parts, save the String resource to a local variable, and then apply the different Html commands to the desired parts.

Also see here and for the allowed Html tags here

Noltibus
  • 1,300
  • 3
  • 12
  • 34