[英]Change line after add image in SpannableStringBuilder
I am adding 'xyz' text in SpannableStringBuilder
I can change line at the time image add so image comes in next line but after added image, I want cursor position in next line so if I write any text after adding an image it should be come from next line. 我在
SpannableStringBuilder
添加'xyz'文本,我可以在添加图像时更改行,从而使图像进入下一行,但是在添加图像之后,我希望光标位于下一行,因此,如果我在添加图像后写了任何文本,都应该出现从下一行开始。
int selectionCursor = mEdtComment.getSelectionStart();
mEdtComment.getText().insert(selectionCursor, "\n" + ".");
selectionCursor = mEdtComment.getSelectionStart();
SpannableStringBuilder builder = new SpannableStringBuilder(mEdtComment.getText());
builder.setSpan(new ImageSpan(mRotateBitmap), selectionCursor - ".".length(), selectionCursor,
Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
mEdtComment.setText(builder);
mEdtComment.setSelection(selectionCursor);
mEdtComment.setSelection(selectionCursor);
用下面的行替换上面的行:
mEdtComment.setSelection(mEdtComment.getText().length());
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.