[英]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. 我知道使用padding的textCursorDrawable大小。 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.
这样做有两个潜在的问题-1.它的API 12+(我们支持9及更高版本),尽管这没什么大不了的。2.我无法找到以编程方式重置它的方法,只能在xml定义中看到对其的访问。
Any ideas? 有任何想法吗?
Chances are the ImageSpan changes the lineheight after it's added. 添加后,ImageSpan可能会更改lineheight。 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) (我没有机会测试我刚刚写的内容,所以这只是一个理论)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.