I cannot get SpannableString to work when I install AppTheme in Theme.AppCompat.Light.DarkActionBar.
I have a button, and its text is set using SpannableString. When I use the Golo theme, the text is displayed as expected, but when I switch to the AppCompat theme, the effects effects seam is ignored. How to make SpannableString work using AppCompat theme?

styles.xml - when switching between these two themes, I get very different results ...
<resources>
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar" />
</resources>
... for my button that uses a SpannableString
public static class PlaceholderFragment extends Fragment {
public PlaceholderFragment() {
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_main, container, false);
Button button = (Button) rootView.findViewById(R.id.button);
String detail = "ABC";
String caption = String.format("2 %s", detail);
Spannable span = new SpannableString(caption);
int detailIndex = caption.indexOf(detail);
span.setSpan(new StyleSpan(Typeface.BOLD), 0, detailIndex, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
span.setSpan(new RelativeSizeSpan(0.5f), detailIndex, detailIndex+detail.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
button.setText(span);
return rootView;
}
}
Aegir source
share