You can simulate this effect by drawing two texts side by side with alpha balancing (between 127 and 255) between two elements.
Suppose your text moves from bottom to top and your current vertical position is 10.28. You just need to draw one text at position 10 with an alpha close to 127, and another text at position 11 with an alpha close to 255.
Here is a bit (ugly: D) example:
private void doDraw(Canvas canvas) { Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG); paint.setColor(Color.BLACK); paint.setTextSize(20); canvas.drawRect(0, 0, getWidth(), getHeight(), paint); mY += 0.05f; paint.setColor(Color.RED); if (Math.floor(mY) == mY) { canvas.drawText("test", mX, mY, paint); } else { float mY1 = (float) Math.floor(mY); float mY2 = mY1 + 1; float delta = mY - mY1; paint.setAlpha((int) ((1 - delta) * 127) + 127); canvas.drawText("test", mX, mY1, paint); paint.setAlpha((int) ((delta) * 127) + 127); canvas.drawText("test", mX, mY2, paint); } }
Days
source share