Search code examples
androidhighlightingandroid-edittext

setCursorVisible loses highlighting


I set setCursorVisible(false) on my EditText to get rid of the blinking cursor. Unfortunately, this also gets rid of highlighting. Why? How can I get rid of the cursor and not the highlighting?


Solution

  • Just glanced at the code for TextView... seems it only draws the selection highlight when the private member mCursorVisible is true. The behaviour you're seeing is evidently by design.

    To workaround it I'd try creating and setting a BackgroundColorSpan from the current selection.