如何检测 TextView 是否包含 SpannableStringBuilder

AVE*_*imi 1 android textview spannablestring

如何找出是否TextView包含SpannableStringBuilder而不是纯文本?我需要更改 的文本大小TextView,但如果它包含纯文本或跨度,则不同。

TextView textView1;
textView1.setText("BlahBlahBlah");

TextView textView2;
final SpannableStringBuilder sb = new SpannableStringBuilder(title);
                                                        final ForegroundColorSpan fcs = new ForegroundColorSpan(Color.rgb(255,255,255));
                                                        sb.setSpan(fcs,  bookname.length(),title.length(), Spannable.SPAN_INCLUSIVE_INCLUSIVE);
textView2.setText(sb);
Run Code Online (Sandbox Code Playgroud)

现在我需要一个这样的方法:textView1.hasSpans()

roy*_*oyB 6

instanceOf

 final CharSequence text = textView.getText();
 if(text instanceof Spannable){
    ...
Run Code Online (Sandbox Code Playgroud)

我正在使用它,setFilter所以没有理由在这里不起作用