在Android中为古吉拉特语和印地语提供语言支持

And*_*007 5 android

大家好知道我们如何支持Android中的印地语和古吉拉特语言支持.我使用下面的代码,但不支持,我只看到框.

我把字符串文件放在res/values-hi/string.xml文件夹中.印地语有一些关键价值.它用于印地语:

Locale locale = new Locale("hi");
Locale.setDefault(locale);
Configuration config = new Configuration();
config.locale = locale;     
getBaseContext().getResources()
                .updateConfiguration(config,getBaseContext().getResources().getDisplayMetrics());
Run Code Online (Sandbox Code Playgroud)

任何人都知道,请给我解决方案.

Kri*_*Kri 8

由于Android不支持古吉拉特语和印地文语言,您仍然可以为您的应用程序提供支持.

对于Gujarati,将C:\WINDOWS\Fonts\Shruti.TTF文件复制到Assets文件夹,单击此处以了解如何创建assets文件夹, 然后使用以下代码.

TextView text_view = new TextView(this);

Typeface font = Typeface.createFromAsset(getAssets(), "Shruti.TTF");

text_view.setTypeface(font);

text_view.setText("???????");
Run Code Online (Sandbox Code Playgroud)

Shruti.TTF文件是古吉拉特语字体.同样,您可以添加对hindi文件的支持.