首行缩进效果

mContentEditText.setOnKeyListener(new OnKeyListener() {


@Override
public boolean onKey(View v, int keyCode, KeyEvent event) {
// 这两个条件必须同时成立,如果仅仅用了enter判断,就会执行两次
if (keyCode == KeyEvent.KEYCODE_ENTER && event.getAction() == KeyEvent.ACTION_DOWN) {
// 执行发送消息等操作
new Handler().postDelayed(new Runnable() {


@Override
public void run() {
int index = mContentEditText.getSelectionStart();
Editable editable = mContentEditText.getText();
editable.insert(index, "\u3000\u3000");
mContentEditText.setSelection(index + 2);
}
}, 10);
return false;
}
return false;
}
});

你可能感兴趣的:(首行缩进效果)