title: Align text around ImageSpan center vertical
body: <p>I have an <a href="https://developer.android.com/reference/android/text/style/ImageSpan.html" rel="noreferrer"><code>ImageSpan</code></a> inside of a piece of text. What I've noticed is that the surrounding text is always drawn at the bottom of the text line -- to be more precise, the size of the text line grows with the image but the baseline of the text does not shift upward. When the image is noticeably larger than the text size, the effect is rather unsightly. </p>
  
  <p>Here is a sample, the outline shows bounds of the <code>TextView</code>:
  <img src="https://i.stack.imgur.com/fYT1i.png" alt="enter image description here"></p>
  
  <p>I am trying to have the surrounding text be centered vertically with respect to the image being displayed. Here is the same sample with blue text showing the desired location:</p>
  
  <p><img src="https://i.stack.imgur.com/O1sX4.png" alt="enter image description here"></p>
  
  <p>Here are the constraints that I'm bound by:</p>
  
  <ul>
  <li>I cannot use compound drawables. The images must be able to be shown between words.</li>
  <li>The text may be multiline depending on the content. I have no control over this.</li>
  <li>My images are larger than the surrounding text and I cannot reduce their size. While the sample image above is larger than the actual images (to demonstrate the current behavior), the actual images are still large enough that this problem is noticeable.</li>
  </ul>
  
  <p>I've tried using the <code>android:gravity="center_vertical"</code> attribute on the TextView, but this does not have any effect. I believe this just vertically centers the text <em>lines</em>, but within the text line the text is still drawn at the bottom. </p>
  
  <p>My current train of thought is to create a custom span that shifts the baseline of the text based on the height of the line and the current text size. This span would encompass the entire text, and I would have to compute the intersection with the <code>ImageSpan</code>s so I can avoid shifting the images as well. This sounds rather daunting and I'm hoping someone can suggest another approach.</p>
  
  <p>Any and all help is appreciated!</p>