【问题标题】:How to achieve EditText inputType: DONE button one keyboard + wrapping to next line如何实现EditText inputType:DONE按钮一个键盘+换行到下一行
【发布时间】:2018-01-16 19:07:51
【问题描述】:

我正在尝试实现精确的 inputType,但没有成功。

条件如下

  • DONE 按钮在键盘上可见
  • 文本超过 1 行时,换行到下一行
  • 最大高度,例如 3 行

知道怎么获得吗?

【问题讨论】:

  • 键盘是它自己的应用程序。它可以决定在那个按钮上放什么,你不能强迫任何通用键盘做任何事情。充其量你可以给它一些提示。但大多数键盘只会默认为多行字段中的换行符。

标签: android android-layout android-edittext android-inputtype


【解决方案1】:

如果你想使用 DONE 按钮,你不能只使用单行来使用多行

 <EditText
       android:imeOptions="actionDone" // for adding DONE Button
       android:inputType="textMultiLine" // for using multi lines , DONE Button will be disappeared. Use “text” instead.
       android:maxLines="3" // 3 lines maximum 
       />

控制DONE按钮

 editText.setOnEditorActionListener(new TextView.OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView textView, int i, KeyEvent keyEvent) {
            if (i == EditorInfo.IME_ACTION_DONE){
                // What do you want to do when clicking on Done Button
                return true;
            }
            return false;
        }
    });

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-12-28
    • 1970-01-01
    • 1970-01-01
    • 2011-02-03
    • 1970-01-01
    • 2017-01-13
    • 1970-01-01
    • 2015-12-21
    相关资源
    最近更新 更多