Android EditText with word-wrap but no hard returns

后端 未结 3 1973
小鲜肉
小鲜肉 2020-12-31 11:07

If I set SingleLine=true on an EditText widget, I get a single-line edit control that doesn\'t allow hard returns to be inserted by the user (clicking Enter moves to the nex

3条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-31 11:43

    I was interested in this, and realized that the built-in Android messaging app has wrapped text without the enter key on the soft keyboard. According to the source layout here, it's done with the following options. Not all are necessary; I believe the key is to have textShortMessage, textMultiLine, and flagNoEnterAction:

    android:inputType="textShortMessage|textAutoCorrect|textCapSentences|textMultiLine"
    android:imeOptions="actionSend|flagNoEnterAction"
    

提交回复
热议问题