简体   繁体   中英

How can I prevent the cursor from resizing in an EditText (MultiAutoCompleteTextView) after I add an imagespan using a SpannableStringBuilder?

Here is what it looks like in the beginning when I haven't added any imagespan chips -

在此处输入图片说明

As you can tell there the cursor is placed at the right size and the gravity is respected.

Then when I add an imagespan, the cursor all of a sudden becomes bigger like this -

在此处输入图片说明

I don't understand why this happens and I also don't know how to fix it, ie keep the cursor the same size.

Finally when I start typing again, the cursor is all wierd while maintaining the size of the of the font and the span also moves a little to the bottom. I really want to the keep the cursor the same size and keep it centered

在此处输入图片说明

I'm aware of textCursorDrawable sizing using padding. There are two potential problems with that - 1. Its API 12+ (We support 9 and above), this isnt a big deal though 2. I couldnt find a way to reset it programmatically, only saw access to it in the xml definition.

Any ideas?

Chances are the ImageSpan changes the lineheight after it's added. If you set a line height bigger than the imagespan, I have a feeling your cursor will remain constant size (but still large). At this point you can add padding to shrink it down to the smaller size you want and it should remain constant.

(I don't have a chance to test what I just wrote, so it's just a theory)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM