The image is from an app called kakao story
.
Suppose there's a post with a list of comments like any sns apps.
When you click a comment, it inserts the user name of the commenter in the edit-text to indicate my new comment is a reply to the user
.
(You can't add the same name more than once.)
When you hit backspace to delete the name, the entire characters that make up the name(e.g., chabeau in the example) will be deleted by 1-backspace.
I'm trying to mimic the behavior and want some pointers how to implement it or what to search for.
If you are in search of bubble view. You can achieve it by creating a subclass of android.text.style.DynamicDrawableSpan.ImageSpan
which will convert a portion of EditText
string into formatted span
.
This SO Question will give you some basic idea about creating formatted span.
This is a good tutorial for customizing editext
with spans
.
And for deleting whole word at once, you can use SPAN_EXCLUSIVE_EXCLUSIVE property.
Below code will format the first four character of the string, Hope this will give you some hint.
final SpannableStringBuilder sb = new SpannableStringBuilder("your text here");
final ForegroundColorSpan fcs
= new ForegroundColorSpan(Color.rgb(158, 158, 158));
// Span to set text color to some RGB value
sb.setSpan(fcs, 0, 4, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
yourTextView.setText(sb);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With