Android 5.0: Issue with setSpan in TextView

383 views Asked by At

I'm trying to implement WordCap in a TextView on Android, here is my code:

SpannableStringBuilder span = new SpannableStringBuilder();         
span.append(" ");
span.append(str);   
Drawable localDrawable = tvText.getResources().getDrawable(R.drawable.none);
localDrawable.setBounds(0, 0, 105, 1);
ImageSpan isp = new ImageSpan(localDrawable);           
span.setSpan(isp, 0, 1, Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
tvText.setText(span);

Result:

It works fine until I upgrade to Android 5.0 (Lollipop). The drawable setBound is not working anymore. It looks like this:

I still can't find a solution to fix this. Please help! Thanks a lot.

0

There are 0 answers