I have a problem with striking through a part of text that is displayed in the button. I'm trying to achieve the effect using SpannableString and StrikethroughSpan. I have the following method:
public static SpannableString strikethrough(SpannableString text) {
StrikethroughSpan span = new StrikethroughSpan();
text.setSpan(span, 0, text.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
return text;
}
Then I do something like this
SpannableString strikethoughPart = new SpannableString("striked_part");
TextStyleHelper.strikethrough(strikethoughPart);
final CharSequence concatted = TextUtils.concat("not striked ", strikethoughPart);
justButton.setText(concatted);
justText.setText(concatted);
The TextView is displayed correctly, with one part seen as striked. However, the button is displayed not correctly, there is no strikethrough effect (the same on all apis from 21 to 25) api 21 image.
API 26+ works as expected api 26 image. How can I strikethrough only part of the button text on lower apis (21-25)? I can achieve the effect of striking through with setPaintFlags method but that will strike through all text and I don't need that.
Tried classes of button: usual Button and MaterialButton.