0

在我的应用程序中,我想将我的英文字体转换为印地语,为此我进行了本地化。较低版本(即 2.3)不支持。然后我下载了“ shusha.ttf ”文件并添加到 assets/fonts 文件夹中。然后我为 textviews 设置字体。像这样我能够将英文字体转换为印地语。但是当我从文本视图中获取文本时,它没有以印地语显示(获取英文字体)。我正在使用该文本通过 gmail 发送邮件。

如果有人对此有想法,请给我一个建议。

这是我的代码

 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);
4

3 回答 3

2

不要使用和使用字体,而是使用 UNICODE 字符作为印地语单词。我已经为我的一个项目完成了它,并且效果很好。

于 2013-11-14T12:49:40.643 回答
0

您必须更改文本视图文本的字体。

首先将字体放在您的资产文件夹中。

然后在你的java文件中添加这样的代码来改变你的字体:

Typeface myTypeface = Typeface.createFromAsset(this.getAssets(),
                    "shusha.ttf");
TextView digital= (TextView) findViewById(R.id.your_textView);
            digital.setTypeface(myTypeface);

将 shusha.ttf 放在项目的资产文件夹中。

这可能会对您有所帮助。

于 2013-11-14T12:36:28.563 回答
0

在值/样式中创建样式,例如,

<style name="MyStyle" parent="@android:style/Theme">
        <item name="typeface">font_in_assest.ttf</item>
</style>

在这里,font_in_assest.ttf 是您放置在您的资产/字体中的字体。然后为您分配样式,

<TextView
        android:id="@+id/title"
        style="@style/MyStyle"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="@string/hello_world" />   

对你会有帮助。。

于 2013-11-14T12:45:42.127 回答