Implementing ATM Numeric input behaviour in Androi

2019-09-19 10:27发布

问题:

How can I implement the following input behaviour using EditText in Android. Is there a existing library to implement this behaviour or if else, what would the logic be like? This behaviour can be seen on ATM machines as well.

Here's a gif that demonstrates this behaviour in an Android app:

As observed, the input starts with the last digit and proceeds to the left while appending necessary commas and decimal separation (2 decimals). I couldn't find any library that implements this behaviour.

Can you point me in the right direction with an existing implementation or a library?

回答1:

I resolved this and built a custom library based on Subhechhu Khanal's link to a resolved thread. Anyone who needs this behaviour can use the custom library and customise it as required.

ATM-EditText Library: https://github.com/dinukapj/ATM-EditText

I encourage the community to make this library better. Thanks!