【问题标题】:Drawing Layers over ImageView in Android在 Android 中的 ImageView 上绘制图层
【发布时间】:2011-11-12 20:08:33
【问题描述】:

谁能指导我如何在 ImageView 组件上显示的图像上放置不同的绘图层。 基本上我想在我的绘图应用程序中实现撤消和重做功能。

目前我可以在图像上放置文本或绘图,但无法实现撤消/重做功能。我想知道这可以通过维护一些分层的东西来实现。

请帮帮我。

这是我当前的绘图代码..

    try {

        image.buildDrawingCache();
        Bitmap bitmap = image.getDrawingCache();

        try

        {

            bitmap = getResizedBitmap(bitmap, image.getHeight(),
                    image.getWidth());

        } catch (OutOfMemoryError e) {
            Toast.makeText(getApplicationContext(), e.getMessage(), 1)
                    .show();
        }

        TextPaint tp = new TextPaint();
        tp.setColor(Color.GREEN);
        tp.setAntiAlias(true);
        tp.setTextSize(30);

        Canvas canvas = new Canvas(bitmap);
        canvas.drawText(input.getText().toString(), xPos, yPos, tp);
        image.setImageBitmap(bitmap);

        input.setText("");
        input.setVisibility(View.INVISIBLE);

    } catch (Exception e) {

        Toast.makeText(getApplicationContext(), e.getMessage(), 1).show();
    }

提前谢谢...!!!

【问题讨论】:

    标签: android drawing layer undo redo


    【解决方案1】:

    以另一种方式完成。 创建原始位图并将其保存在某个位图变量中。现在,在每次 onDraw 调用时,都会使用原始的位图启动位图并将其传递给画布。然后做你想做的事..

    【讨论】:

    • 已经很久了,我会寻找代码,如果找到会帮助你。
    • 我已经实现了你所解释的。无需您搜索代码。非常感谢,尝试用图像、文本和路径实现撤消一段时间。终于搞定了。
    • 谢谢一些好东西...我从该代码中记得就像在几个列表中维护一堆绘图操作并简单地推送弹出项目...
    【解决方案2】:
    猜你喜欢
    • 2016-11-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多