我正在开发一个应用程序。我需要在文本视图上设置印度卢比的符号,该文本视图设置为金额。
符号:
我在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。
那么我应该遵循哪些步骤来做到这一点......
嗨在字符串中使用它
印刷卢比符号:<string name="Rs">\u20B9</string>
对于打印Rs文本:<string name="rs">\u20A8</string>
如果你想打印\u20B9
,请使用Rupee Symbol
和
如果你想打印\u20A8
,请使用"Rs"
试试这个,而不是Rupee_Foradian.ttf
使用Rupee.ttf
它会工作。我得到货币符号。
Typeface tf = Typeface.createFromAsset(getAssets(), "font/Rupee.ttf");
textView1.setTypeface(tf);
textView1.setText("`");
复制粘贴unicode₹到XML或Java,它工作得很好。有关unicode的更多信息,请参阅http://www.fileformat.info/info/unicode/char/20b9/index.htm
在适配器上使用
Viewholder.price.setText("Price: \u20B9"+dataAdapterOBJ.getPrice());
试试这个代码片段,它在Xamarin.Forms
中正常工作
CultureInfo india = new CultureInfo("hi-IN");
var rupeeSymbol = india.NumberFormat.CurrencySymbol;
public static String getIndianRupee(String value) {
Format format = NumberFormat.getCurrencyInstance(new Locale("en", "in"));
return format.format(new BigDecimal(value));
}