嗨,我也面临同样的问题,最后我得到了解决方案.
更改
android:inputType="textMultiLine"
至
android:inputType="text"
和
在.java文件中,使用id访问EditText
editText.setHorizontallyScrolling(false);
editText.setMaxLines(3);
现在在editText上实现OnEditorAction.
editText.setOnEditorActionListener(new TextView.OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
if (actionId == 4) { //actionId 4 for actionDone And 6 for actionSend
//perform action what you want
return true;
} else
return false;
}
});