клавиатура с числовыми и основными математическими операциями для EditText - PullRequest
0 голосов
/ 04 ноября 2019

Как у меня может быть эта клавиатура

enter image description here

для EditText?

Я пробовал с InputType, но у меня не могло быть этогоклавиатура.

Я создал этот пример, который показывает, что ответы не решают проблему:

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">

    <com.google.android.material.textfield.TextInputLayout
        android:id="@+id/textInputLayout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:layout_constraintTop_toTopOf="parent">

        <!--number-->
        <com.google.android.material.textfield.TextInputEditText
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:hint="hint"
            android:inputType="number" />
    </com.google.android.material.textfield.TextInputLayout>

    <!--numberDecimal|numberSigned-->
    <EditText
        android:id="@+id/editText"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:ems="10"
        android:inputType="numberDecimal|numberSigned"
        android:digits="0123456789.+-*/%()"
        app:layout_constraintTop_toBottomOf="@+id/textInputLayout" />

    <!--numberPassword-->
    <EditText
        android:id="@+id/editText2"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:ems="10"
        android:inputType="numberPassword"
        app:layout_constraintTop_toBottomOf="@+id/editText" />

</androidx.constraintlayout.widget.ConstraintLayout>

приведенные клавиатуры для первых двух типов ввода одинаковы: enter image description here

и последний:

enter image description here

Ответы [ 2 ]

0 голосов
/ 04 ноября 2019

Вы можете использовать это для отображения только чисел:

<EditText
        android:id="@+id/editTextNumber"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:inputType="number" />

Или использовать это для отображения чисел, когда вы используете EditText для паролей:

<EditText
        android:id="@+id/editText"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:inputType="numberPassword" />

Пожалуйста, поймите, что в большинстве случаев каждыйтелефон имеет другой дизайн клавиатуры, поэтому вы можете не получить ту клавиатуру, которую вы упомянули на картинке

0 голосов
/ 04 ноября 2019

используйте это

<EditText
        android:id="@+id/editText3"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:inputType="number" />
...