I want to allow the user to enter numbers with a decimal separator (comma or dot) depending on the region.
Now I'm using DigitsKeyListener
to enable comma as separator for some locales (e.g. Poland, Germany).
val separator = DecimalFormatSymbols.getInstance().decimalSeparator
editTextValue.keyListener = DigitsKeyListener.getInstance("-0123456789$separator")
This code is written in kotlin.
If software keyboard is Gboard
or other third party keyboard, then everything is fine and user can use comma or dot as separator.
But when user use stock keyboard and DigitsKeyListener
is set, then not all keys are visible and user is not able to add separator.
This is my EditText code:
<android.support.design.widget.TextInputLayout
android:id="@+id/textInput"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
app:hintTextAppearance="@style/Lorin.Theme.TextInputLayout"
app:layout_constraintLeft_toRightOf="@id/imageInfo"
app:layout_constraintRight_toLeftOf="@id/buttonHistoryNumeric">
<android.support.design.widget.TextInputEditText
android:id="@+id/editTextValue"
style="@style/Lorin.EditText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:imeOptions="flagNavigateNext"
android:inputType="number|numberSigned|numberDecimal"
android:maxLines="1"
tools:hint="Range"/>
</android.support.design.widget.TextInputLayout>
val separator = DecimalFormatSymbols.getInstance().decimalSeparator
//editTextValue.keyListener = DigitsKeyListener.getInstance("-0123456789$separator")
When line with DigitsKeyListener
is commented, key for separator is visible but only available separator is dot
Do you have any ideas how to use comma as separator on stock keyboard?
from Decimal separator key not visible when DigitsKeyListener is set
No comments:
Post a Comment