在文本视图上设置印度卢比符号

Man*_*gde 77 android android-fonts

我正在开发一个应用程序.我需要在文本视图上设置印度卢比的符号,该文本视图设置为金额.

符号:

在此输入图像描述

我在Assets/fonts文件夹中有这个字体或.TTF文件.

我试着用它作为:

Typeface typeFace_Rupee = Typeface.createFromAsset(getAssets(),fonts/Rupee_Foradian.ttf");
TextView tvRupee = (TextView) findViewById(R.id.textview_rupee_mlsaa);
tvRupee.setTypeface(typeFace_Rupee);

// Tried to set symbol on text view as follows.
tvRupee.setText("`");
Run Code Online (Sandbox Code Playgroud)

如上面的设置字体我得到空指针错误.

在选择字体并输入`之后的word文件中,我们得到了符号.但它不适用于android.

那么我应该遵循哪些步骤来做到这一点......

and*_*eek 184

在此输入图像描述

嗨在字符串中使用它

印刷卢比符号: <string name="Rs">\u20B9</string>

对于打印Rs文本: <string name="rs">\u20A8</string>


San*_*ain 17

使用\u20B9,如果你想打印Rupee Symbol

使用\u20A8,如果你要打印"Rs"

  • 尝试使用https://gist.github.com/john1jan/a82912fb355771e565bea1720439c5dc.它前缀卢比符号,并添加甚至给逗号分隔金额 (2认同)

Mur*_*san 10

试试这个,而不是Rupee_Foradian.ttf使用Rupee.ttf 它将起作用.我得到货币符号.

Typeface tf = Typeface.createFromAsset(getAssets(), "font/Rupee.ttf");
textView1.setTypeface(tf);
textView1.setText("`");
Run Code Online (Sandbox Code Playgroud)


小智 6

在适配器上使用

Viewholder.price.setText("Price: \u20B9"+dataAdapterOBJ.getPrice());
Run Code Online (Sandbox Code Playgroud)


小智 5

您只需按Alt+ Ctrl+4