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

时间:2013-03-01 13:19:08

标签: android android-fonts

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

符号:

enter image description here

我在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("`");

如上所述设置字体我得到空指针错误。

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

那么我应该遵循哪些步骤......

10 个答案:

答案 0 :(得分:170)

enter image description here

你好在字符串

中使用它

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

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

答案 1 :(得分:15)

如果要打印\u20B9,请使用Rupee Symbol
如果要打印\u20A8

,请使用"Rs"

答案 2 :(得分:10)

试试这个,而不是Rupee_Foradian.ttf使用Rupee.ttf它会起作用。我正在获得货币符号。

Typeface tf = Typeface.createFromAsset(getAssets(), "font/Rupee.ttf");
textView1.setTypeface(tf);
textView1.setText("`");

答案 3 :(得分:3)

将unicode₹复制粘贴到XML或Java,它可以正常工作。有关unicode的更多信息,请参阅 http://www.fileformat.info/info/unicode/char/20b9/index.htm

答案 4 :(得分:3)

在适配器上使用

Viewholder.price.setText("Price: \u20B9"+dataAdapterOBJ.getPrice());

答案 5 :(得分:2)

您只需按 Alt + Ctrl + 4

答案 6 :(得分:0)

尝试使用此代码段,它在Xamarin.Forms

中正常工作
 CultureInfo india = new CultureInfo("hi-IN");

 var rupeeSymbol = india.NumberFormat.CurrencySymbol;

答案 7 :(得分:0)

 public static String getIndianRupee(String value) {
    Format format = NumberFormat.getCurrencyInstance(new Locale("en", "in"));
    return format.format(new BigDecimal(value));
}

答案 8 :(得分:0)

您可以使用Flutter的以下代码行

set (CMAKE_CXX_FLAGS "-lstdc++fs -std=c++17")

答案 9 :(得分:0)

简单写下这段代码:

Text(
  '\u{20B9}${2880.0}',
  textAlign: TextAlign.start,
  style: TextStyle(
      color: const Color(0xFF000000),
      fontSize: 15.0,
      fontWeight: FontWeight.w300),
)