How to enter a "Negative Decimal Number" in EditText? How to enter a "Negative Decimal Number" in EditText? android android

How to enter a "Negative Decimal Number" in EditText?


You can use both with the "|" operator. Just specify "numberSigned|numberDecimal".


Add this in the layout of the EditText:

android:digits="0123456789-."

You can specify more there, for example if you want the user to input sin() functions.


As @a11n says, you can use the pipe operator to specify both:

<EditText    ...    android:inputType="numberSigned|numberDecimal"    ... />

Valid numbers: positive and negative decimal and whole numbers.