'Set Indian Rupee symbol on text view
I am developing an application. And i need to set the symbol of Indian rupee on text view which is set with the text as amount.
Symbol:

I am having the font or .TTF file of this in Assets/fonts folder.
And i tried to use it as :
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("`");
As above setting font i got null pointer error.
In word file after choosing font and typing ` we got the symbol. but it is not working in android.
So what steps should i follow to do this...
Solution 1:[1]
Use \u20B9 if you want to print the Rupee Symbol
and
Use \u20A8 if you want to print "Rs"
Solution 2:[2]
use on Adapter
Viewholder.price.setText("Price: \u20B9"+dataAdapterOBJ.getPrice());
Solution 3:[3]
Try this, Instead of Rupee_Foradian.ttf use Rupee.ttf it will work. am getting currency symbol.
Typeface tf = Typeface.createFromAsset(getAssets(), "font/Rupee.ttf");
textView1.setTypeface(tf);
textView1.setText("`");
Solution 4:[4]
You can simply press Alt + Ctrl + 4
Solution 5:[5]
Copy-paste the Unicode ? to XML or Java and it works just fine. For more info on the Unicode refer http://www.fileformat.info/info/unicode/char/20b9/index.htm
Solution 6:[6]
public static String getIndianRupee(String value) {
Format format = NumberFormat.getCurrencyInstance(new Locale("en", "in"));
return format.format(new BigDecimal(value));
}
Solution 7:[7]
Try this code snippet it's working fine in Xamarin.Forms
CultureInfo india = new CultureInfo("hi-IN");
var rupeeSymbol = india.NumberFormat.CurrencySymbol;
Solution 8:[8]
you can go with the below line of code for Flutter
child: Text('\u20B9 ${tx.amount}',
Solution 9:[9]
In 2022, to set number into Indian currency with currency symbol Example:
double rupee = list.getAmount();
String x = NumberFormat.getCurrencyInstance(new Locale("en","in")).format(rupee);
no need of any file etc, currency in Indian format that is comma after three digit from right with rupee symbol
Solution 10:[10]
Just simple write this code :
Text(
'\u{20B9}${2880.0}',
textAlign: TextAlign.start,
style: TextStyle(
color: const Color(0xFF000000),
fontSize: 15.0,
fontWeight: FontWeight.w300),
)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
