【发布时间】:2020-02-29 22:26:21
【问题描述】:
我怎样才能拥有这个键盘
对于 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>
最后一个是这样的:
【问题讨论】:
-
请附上此edittext的代码,如果存在此类问题,请尝试在另一台设备上进行测试
-
我改进了这个问题。
-
如果你想做一个计算器,那么你应该实现你自己的键盘,AFAIK。这并不难,只是一个带有一些TextViews的GridView。而且,是的,TextViews 确实响应点击。
标签: android android-edittext keyboard android-inputtype