HTextView icon indicating copy to clipboard operation
HTextView copied to clipboard

The `sextText("")` doesn't work

Open ApoloRossi opened this issue 7 years ago • 2 comments

I'm using the evaporateText and the animateText("") provide the text with the effect but when I open the view i just need to set a text without the effect then I shoud use the `setText" but it does not work and put nothing on the view.

There is a way to use an evaporate with no effects?

ApoloRossi avatar Oct 25 '17 12:10 ApoloRossi

Any update on this?

prathameshtal avatar May 25 '18 07:05 prathameshtal

This is because it is overriding the ondraw() method of the class TextView. Use the following class and call MyScaleTextView.animateText(CharSequence text, boolean animate), to display text without any animation.

public class MyScaleTextView extends HTextView {
    private ScaleText scaleText;

    private boolean animate = true;

    public MyScaleTextView(Context context) {
        this(context, null);
    }

    public MyScaleTextView(Context context, AttributeSet attrs) {
        this(context, attrs, 0);
    }

    public MyScaleTextView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        scaleText = new ScaleText();
        scaleText.init(this, attrs, defStyleAttr);
        setMaxLines(1);
        setEllipsize(TextUtils.TruncateAt.END);
    }

    @Override
    public void setAnimationListener(AnimationListener listener) {
        scaleText.setAnimationListener(listener);
    }

    @Override
    protected void onDraw(Canvas canvas) {
        if (!animate) {
            super.onDraw(canvas);
        } else {
            scaleText.onDraw(canvas);
        }
    }

    @Override
    public void setProgress(float progress) {
        scaleText.setProgress(progress);
    }

    @Override
    public void animateText(CharSequence text) {
        this.animate = true;
        scaleText.animateText(text);
    }

    public void animateText(CharSequence text, boolean animate) {
        this.animate = animate;
        if (animate){
            scaleText.animateText(text);
        }else {
            setText(text);
        }
    }
}

I think the developers should also update the library

rohit-sharma-92 avatar Jun 18 '18 06:06 rohit-sharma-92