向软键盘添加*和#键

问题描述 投票:1回答:1

1]问题:

我有一个EditText,用户必须在其中输入USSD代码。

问题是,要输入USSD代码,用户必须切换到符号键盘(两次至三次),这会带来非常糟糕的用户体验。

USSD代码示例: * 345 * 77#,* 333 * 25#,* 123 * 678#等

<EditText
        android:id="@+id/field_code"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:imeActionId="@integer/imo_action_search"
        android:imeOptions="actionSearch"
        android:inputType="phone" /> 

enter image description here

2)我需要什么:如何使用*和按钮替换加亮的按钮(下图),而不使用自定义键盘?

enter image description here

3)我尝试过的!!

1)所有EditText的InputType。

2)Google的问题,我发现的唯一解决方案是自定义键盘 但我想知道是否有任何简单的解决方案

android android-softkeyboard custom-keyboard
1个回答
0
投票

每个键盘应用都有自己的布局,您无法更改。例如,android:inputType="phone"GboardSwiftKey上具有不同的布局。enter image description here

解决方案:您应该实现自定义InAppKeyboard并将其显示给用户,而不是系统键盘。“ Creating an In-App Keyboard for your Android Apps”是一个很好的教程,描述了如何开发这样的自定义InAppKeyboard,但是您可以设计所需的布局并使用轻松在您的应用程序中。

enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.