I have a user who owns an LG VS890 4G with Android 4.4.2. Apparently each time when he tries to insert a minus in my lat/long coordinate input EditText
, his minus gets converted into a dot. He experiences the same problem if he is pasting the negative coordinate into the EditText
.
<EditText
android:id="@+id/long_degrees_et_id"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="10"
android:inputType="number|numberSigned|numberDecimal" >
The thing is that he is experiencing this only while using the soft keyboard. On the hard keyboard it works as expected.
Here is a screenshot with his phone while trying to input the coordinates:
I know that this is an inputType
problem because I gave him a build with no inputType
and it woks fine (except that his keyboard is not opening with the numeric type).
He is the only one who reported this problem and I couldn't reproduce it. I would really like to keep the input type to number so that the keyboard opens automatically to numeric. Any ideas of how can I fix this?
This layout element
<EditText
...
android:inputType="number|numberDecimal|numberSigned"
...
/>
should provide a numeric keyboard view complete with a decimal and sign entry. On most of my devices and emulators the '.' and '-' are on separate buttons, on a Samsung Galaxy S5/SM-G900P/Android 4.4.2 both the '.' and '-' appear oddly on the same button (as shown in the photo above on a LG device, also 4.4.2). It appears on some devices the popup keypad is snafu as it puts both the sign and decimal on the same button.
However, on the first character of the field, if you double click the (.-) button a sign will be entered instead of a decimal. A single click will enter a decimal. The difficulty is putting some text in to explain that trick to your users.
Perhaps this design may have been done on purpose to save button space. (ug, didn't we just land on a asteroid?)
Using this combination does not work as you might hope:
android:inputType="number|numberSigned|numberDecimal"
android:digits="0123456789.-"
Also, do not use android:numeric="decimal" as it is decremented, nor does it address the problem.
@Adrian suggestion of N/S W/E would be a nice addition, however, not an alternative as the - sign is still needed. Some users think in terms of the compass rose, some think -/+.
One solution is to create a custom input method editor (IME). Here is an example custom KeyboardView.
Specific to the entry of Latitude and Longitude coordinates: I'm going to go the custom IME/KeyboardView route and have specific handling for lat/long entry as there are also range values for each field as well.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With