Ничья ReplacementSpan никогда не вызывается в AppWidgetPRovider - PullRequest
0 голосов
/ 13 декабря 2018

У меня есть диапазон цветов фона:

public class PaddingBackgroundColorSpan implements LineBackgroundSpan {

    private int mBackgroundColor;
    private int mPadding;
    private Rect mBgRect;

    public PaddingBackgroundColorSpan(int backgroundColor, int padding) {
        super();
        mBackgroundColor = backgroundColor;
        mPadding = padding;
        // Precreate rect for performance
        mBgRect = new Rect();
    }

    @Override
    public void drawBackground(Canvas c, Paint p, int left, int right, int top, int baseline, int bottom, CharSequence text, int start, int end, int lnum) {
        final int textWidth = Math.round(p.measureText(text, start, end));
        final int paintColor = p.getColor();
        // Draw the background
        mBgRect.set(left - mPadding,
                top - (lnum == 0 ? mPadding / 2 : - (mPadding / 2)),
                left + textWidth + mPadding,
                bottom + mPadding / 2);

        Logger.E("draw", mBgRect);

        p.setColor(mBackgroundColor);
        c.drawRect(mBgRect, p);
        p.setColor(paintColor);
    }
}

, а мой textview находится в android:bufferType="spannable"

Моя проблема в том, что drawBackground никогда не вызывается.

Я тоже пытался с ReplacementSpan, но то же самое случилось с draw

В противном случае простой BackgroundColorSpan работает ...

Любая помощь, почему метод рисованияникогда не звонил в моих пользовательских пролетах?

...