0

I am writing an Android app that uses both single line and multi-line EditTexts with both set for only decimal numbers. When the user clicks in a single line EditText a numeric keyboard opens. However, when the user clicks in a multi-line EditText, a phone keyboard with letters, star, and hash opens (see the attached image). I want a number only keyboard with a return (new line) key for the multi-line EditTexts. I don't want the letters, star, hash, space, etc.

Screen shot of app showing wrong keyboard for multi-line EditText

Here are the attributes that I am using in my XML file:

<EditText
    android:id="@+id/decData"
    android:layout_width="wrap_content"
    android:layout_height="0dp"
    android:layout_weight="1"
    android:allowUndo="true"
    android:background="@drawable/multi_line_edit_text"
    android:digits="01234567890.-\n"
    android:gravity="top|end"
    android:inputType="textMultiLine|numberDecimal"
    android:maxEms="15"
    android:maxLines="20"
    android:minEms="8"
    android:paddingEnd="3dp"
    android:paddingStart="3dp">

How can get the keyboard that I want (only numbers, dot, negative, and return)? Also, why are the multi-line EditTexts behaving differently than the single line? Because of allowing the enter key?

Barzee
  • 897
  • 3
  • 15
  • 30

0 Answers0