在图像视图的触摸事件上填充两个图像叠加,如搜索栏

2024-03-13

有两个图像黑色和蓝色,同时触摸蓝色图像,它应该像进度一样填充,我在不使用画布的情况下使用多个剪切图像实现了但没有得到smoothness触摸时,例如.

实际上,我正在尝试实现类似于我上面提到的 100 个俯卧撑应用程序,我得到了一个link http://blog.publicobject.com/2010/04/shush-ringer-restorer-update.html但这是使用画布实现的,我想使用图像实现,我谷歌但没有运气,任何类似于该应用程序的链接或教程(100 个俯卧撑)?


这是我使用剪辑路径想出的东西。我使用以下图像(编码器颜色),其中背景是实心的,前景图像在透明背景上仅包含蓝色圆圈。第一个背景图像绘制到屏幕上,然后设置剪辑路径,以便在其顶部正确绘制进度图像(前景图像)。

背景图;https://i.stack.imgur.com/Rvxxj.png https://i.stack.imgur.com/Rvxxj.png
前景图像;https://i.stack.imgur.com/1aTdG.png https://i.stack.imgur.com/1aTdG.png

和代码;

private class ProgressView extends View {

    private Bitmap bgBitmap;
    private Bitmap fgBitmap;
    private RectF fullRect = new RectF();
    private Path clipPath = new Path();

    public ProgressView(Context context) {
        super(context);
        bgBitmap = BitmapFactory.decodeResource(
                                   context.getResources(), R.drawable.bg);
        fgBitmap = BitmapFactory.decodeResource(
                                   context.getResources(), R.drawable.fg);
    }

    @Override
    public void onDraw(Canvas c) {
        fullRect.right = getWidth();
        fullRect.bottom = getHeight();

        c.drawBitmap(bgBitmap, null, fullRect, null);

        float angle = SystemClock.uptimeMillis() % 3600 / 10.0f;

        clipPath.reset();
        clipPath.setLastPoint(getWidth() / 2, getHeight() / 2);
        clipPath.lineTo(getWidth() / 2, getHeight());
        clipPath.arcTo(fullRect, -90, angle);
        clipPath.lineTo(getWidth() / 2, getHeight() / 2);
        c.clipPath(clipPath);

        c.drawBitmap(fgBitmap, null, fullRect, null);

        invalidate();
    }   
}

用像样的图像替换我的临时图像并以更合适的方式更新角度应该不会太困难。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

在图像视图的触摸事件上填充两个图像叠加,如搜索栏 的相关文章