Search code examples
androidtextviewclickable

Android: Prevent changing background color of text in TextView with ClickableSpan when touched


I just want to make some text clickable in TextView, so I used ClickableSpan, but the background color of text is changed when I touched it.

This is my code:

ClickableSpan clickableSpan = new ClickableSpan() {
    @Override
    public void onClick(View widget) {
        // do something
    }
};
SpannableString ss = new SpannableString("ClickableSpan Test");
ss.setSpan(clickableSpan, 0, 13, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);

How can I prevent changing background color on touch?


Solution

  • Add this in you textview

    android:textColorHighlight`="#000000"