Странное поведение с использованием TextAppearanceSpan на Kindle Fire - PullRequest
4 голосов
/ 01 декабря 2011

Kindle Fire, кажется, имеет «другой» способ обработки отрезков в SpannableStringBuilder. Я обнаружил, что когда я добавляю TextAppearanceSpan перед ForegroundColorSpan, цвет переднего плана игнорируется. Если я сначала добавлю TextAppearanceSpan, то в ForegroundColorSpan все будет работать нормально. Я не видел такого поведения ни на других устройствах Gingerbread, ни на устройствах Honeycomb ...

FAILS:

        String text = "Styled with TextAppearanceSpan then ForegroundColor";
        int textLen = text.length();
        CharSequence styledText = "";
        SpannableStringBuilder ssb = new SpannableStringBuilder(text);
        ssb.setSpan(new TextAppearanceSpan(null, 0, 32, null, null), 0, textLen, 0);
        ssb.setSpan(new ForegroundColorSpan(0xFFFF0000), 0, textLen, 0);

        styledText = TextUtils.concat(styledText, ssb);
        tv2.setText(styledText);

РАБОТАЕТ:

        String text = "Styled with ForegroundColor then TextAppearanceSpan";
        int textLen = text.length();    
        CharSequence styledText = "";
        SpannableStringBuilder ssb = new SpannableStringBuilder(text);
        ssb.setSpan(new ForegroundColorSpan(0xFFFF0000), 0, textLen, 0);
        ssb.setSpan(new TextAppearanceSpan(null, 0, 32, null, null), 0, textLen, 0);

        styledText = TextUtils.concat(styledText, ssb);
        tv1.setText(styledText);

Кто-нибудь еще видел это или видел документы, описывающие правила для добавления пролетов ???

Спасибо, - Марк

...