1

Smartisan OS 有一个天气 app 有这样的效果:将格式从摄氏更改为华氏时,温度数字会像这样滚动: Motion blur effect sample

我认为这不是数字滚动时的简单模糊效果,因为您可以从图像中看到这些数字仅在垂直方向上模糊。数字首先以低速滚动,然后以更快的速度滚动。并且随着滚动,模糊半径也更长。对我来说,这种效果可不是那么容易达到的。

4

2 回答 2

2

只需创建一个始终在画布上绘制的自定义视图。您必须自己处理上下移动,在这种情况下您将无法使用简单的内置 ui 元素。一旦你想要滚动效果,只需多次绘制移动文本,但每次稍微偏移它并改变它的不透明度,这取决于它的速度。

在这种情况下,使用 OpenGL 可能有点过头了,因为这种情况只是关于文本。运动模糊太难了,而且性能太重而无法实现,并且在画布上绘制十几次文本对性能的影响很小。

希望我能帮上忙。

于 2017-07-15T09:24:10.283 回答
2

@andras 的相同解决方案

 /**
 * use for 2D-Radial-Blur
 *
 * @param src
 * @param dx    It effetcs the speed. you can use 1/-1 for a test
 * @param dy    It effetcs the speed. you can use 1/-1 for a test
 * @param times effects motion length
 * @return
 */
public static Bitmap doRadialBlur(Bitmap src, int dx, int dy, int times) {

    Bitmap dst = Bitmap.createBitmap(src.getWidth(), src.getHeight(), Bitmap.Config.ARGB_8888);

    Canvas canvas = new Canvas(dst);
    Matrix matrix = new Matrix();
    Paint paint = new Paint();
    canvas.drawBitmap(src, matrix, paint);

    paint.setAlpha(51); // 51 / 255 =20%

    for (int i = 0; i < times; i++) {
        matrix.setTranslate(i * dx, i * dy);
        canvas.drawBitmap(src, matrix, paint);
    }

    return dst;
}

https://github.com/dkmeteor/RadialBlur-Android

于 2017-07-25T06:06:11.830 回答