https://github.com/joelarmah/currency-edittext
Currency Editext allows formatting of currency inputs
https://github.com/joelarmah/currency-edittext
android currency edittext kotlin library
Last synced: about 2 months ago
JSON representation
Currency Editext allows formatting of currency inputs
- Host: GitHub
- URL: https://github.com/joelarmah/currency-edittext
- Owner: joelarmah
- License: apache-2.0
- Created: 2024-03-26T13:41:23.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2024-11-20T07:29:52.000Z (over 1 year ago)
- Last Synced: 2025-07-08T05:04:53.513Z (12 months ago)
- Topics: android, currency, edittext, kotlin, library
- Language: Java
- Homepage:
- Size: 1.69 MB
- Stars: 0
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Currency Edittext
This project is a fork of the original [currency-edittext](https://github.com/AbhinayMe/currency-edittext) repository by [Abhinay Me](https://github.com/AbhinayMe).
A Custom EditText implementation that allows formatting of currency-based numeric inputs.
## Installation
Add this in your app's build.gradle file:
```groovy
dependencies {
implementation 'com.github.joelarmah:currency-edittext:1.0.0'
}
```
## Implementation
XML
```
```
Code
```
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
viewBinding = ActivityMainBinding.inflate(layoutInflater)
val view = viewBinding.root
setContentView(view)
viewBinding.currencyEditText.apply {
setCurrency(CurrencySymbols.GHANA) or Use any symbol "$"
setDelimiter(false)
setSpacing(false)
setDecimals(true)
setSeparator(".")
}
}
```
## Customizing
The following attributes can be manipulated:
- Currency by specifying the country
- Spacing between currency and value
- Delimeter
- Decimals
- Thousands Separator Symbol
### Currency
Specify the currency by setting the country of your choice.
```
currencyEditText.Currency = Currency.GHANA;
```
Currency can also be disabled by:
```
currencyEditText.Currency = Currency.NONE;
```
#### Custom Currency/Symbol
If a custom symbol that is not included in the library is required, any string value can be used since the the `Currency` attribute expects a `String` value.
```
currencyEditText.Currency = "TEST";
```
Which produces:
>TEST 450.00
**Note:** Currency is set to your app's Local currency by default.
### Spacing
The spacing between the currency and the value can be specified by:
```
currencyEditText.Spacing = true;
```
**Note:** Spacing is `false` by default.
### Delimeter
The delimeter attribute allows the addition of a `.` symbol after displaying the currency.
> Rs.100
> Rp.100
**Note:** Delimeter is `false` by default.
### Decimals
Decimals can be turned off for the EditText using:
```
currencyEditText.Decimals = false;
```
This outputs the following:
> $100,000
### Separator
The Thousands Separator can be customized as required with any custom symbol to suit the currency formats of different countries. Example: Indonesia -> 12.000.000 (Using . instead of , as the separator)
**NOTE: Decimals must be set as `false` in order avoid conflicts in getting a clean Double or Integer output**
### Getting Clean Output
A `Double` value without Commas, Currency and Decimal places can be retrieved using:
`double cleanOutput = currencyEditText.getCleanDoubleValue();`
An `Integer` value without Commas, Currency and Decimal places can be retrieved using:
`int cleanOutput = currencyEditText.getCleanIntValue();`