Reputation: 59
In my app i want to convert my english font into hindi, for that i did localization. that is not supported for lower versions(i.e 2.3). Then i downloaded "shusha.ttf" file and added to assets/fonts folder. Then i set the typeface for a textviews. Like this i am able to convert the english font to hindi. but when i get the text from the text view it is not showing in Hindi(getting the english font). i am using that text to send the mail through gmail.
If any body have idea about this please give me a suggestion.
This is my Code
t = ((TextView)findViewById(R.id.textView1));
t2 = ((TextView)findViewById(R.id.textView2));
Typeface Hindi = Typeface.createFromAsset(getAssets(), "fonts/shusha.ttf");
t.setTypeface(Hindi);
t.setTextSize(20);
String hello=" Hyderabad, Andhra Pradesh, India ";
t.setText(hello);
String lang=t.getText().toString().trim();
t2.setText(lang);
Upvotes: 0
Views: 1996
Reputation: 1313
Instead of using and playing with font, use UNICODE characters for hindi words. I had done it for a project of mine and it works great.
Upvotes: 2
Reputation: 1780
Create styles in values/styles like,
<style name="MyStyle" parent="@android:style/Theme">
<item name="typeface">font_in_assest.ttf</item>
</style>
Here, font_in_assest.ttf is the font you placed in your assests/fonts. Then assign the style for you view,
<TextView
android:id="@+id/title"
style="@style/MyStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/hello_world" />
It will be helpful for you..
Upvotes: 0
Reputation: 3824
You have to change the font of the text of text view.
First put the font in your asset folder.
Then in your java file add code like this to change your font:
Typeface myTypeface = Typeface.createFromAsset(this.getAssets(),
"shusha.ttf");
TextView digital= (TextView) findViewById(R.id.your_textView);
digital.setTypeface(myTypeface);
Put shusha.ttf in your asset folder of your project.
This will might help you.
Upvotes: 0