EditText - change background color of text (and only text - not the whole view)

后端 未结 1 608
挽巷
挽巷 2020-12-17 05:16

When a user enters information in an EditText, and moves to the next EditText, the information is highlighted as shown below:

相关标签:
1条回答
  • 2020-12-17 05:52

    You can achieve what you want by using a BackgroundColorSpan. You can find more information here:

    http://developer.android.com/reference/android/text/style/BackgroundColorSpan.html

    To use spans you need to build a SpannableString which you can do using a SpannableStringBuilder:

    http://developer.android.com/reference/android/text/SpannableStringBuilder.html

    0 讨论(0)
提交回复
热议问题