title: How does an Android EditText (TextView) draw the blinking cursor?
body: <p>I'm making my own Mongolian vertical script <code>TextView</code> (and <code>EditText</code>) from scratch by extending <code>View</code>. I'm trying to understand how the blinking cursor is implemented in the <a href="https://github.com/android/platform_frameworks_base/blob/master/core/java/android/widget/TextView.java" rel="nofollow noreferrer">Android <code>TextView</code> source code</a>. It seems to be handled by an <code>mEditor</code> instance of the <a href="https://android.googlesource.com/platform/frameworks/base/+/37960c7/core/java/android/widget/Editor.java" rel="nofollow noreferrer"><code>Editor</code> class</a>. In that class I found a <code>drawCursor</code> method:</p>
  
  <pre><code>private void drawCursor(Canvas canvas, int cursorOffsetVertical) {
      final boolean translate = cursorOffsetVertical != 0;
      if (translate) canvas.translate(0, cursorOffsetVertical);
      for (int i = 0; i &lt; mCursorCount; i++) {
          mCursorDrawable[i].draw(canvas);
      }
      if (translate) canvas.translate(0, -cursorOffsetVertical);
  }
  </code></pre>
  
  <p>Apparently, the cursor itself is a <a href="https://developer.android.com/reference/android/graphics/drawable/Drawable.html" rel="nofollow noreferrer"><code>Drawable</code></a> of some type.</p>
  
  <p>So I am finding pieces, but I can't see the forest through the trees. Could someone who understands this better than me tell me in plain English how the blinking cursor works?</p>
  
  <p>Here are some specific points I don't really understand:</p>
  
  <ul>
  <li>The cursor's relationship to the <code>TextView</code> (or <code>EditText</code>), <code>Layout</code>, <code>Editor</code>, and <code>Drawable</code>.</li>
  <li>Every time the cursor blinks, is all the text being redrawn or only the cursor region?</li>
  </ul>
  
  <p><strong>Note:</strong></p>
  
  <p>The accepted answer answers my question as I asked it. However, I would be glad to accept a different answer if anyone can add a more canonical one that explains things in more detail.</p>