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?
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.