简体   繁体   中英

Android - Custom currency symbol

I need a way to display custom currency symbol. I'm using NumberFormat and I can't find a way to replace the currency symbol as it all depends on the locale. the symbol I want to use for currency is a specific symbol for the app I'm working on. any ideas? 🤞

You can put symbols directly into your format pattern and surround them with apostrophes (just in case they are a pattern symbol) instead of using the currency symbol notation.

fun main() {
    val input = 5.47
    val symbol = '\u263a'
    val result = DecimalFormat("'$symbol'#.##").format(input)
    println(result)
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM