如何获取视图的快照?

时间:2018-09-26 23:24:01

标签: android view screenshot

我目前正在使用“视图”来跟踪用户的手指并根据所选择的颜色绘制线条。我已经使用setBackGround()设置了背景图片,但是现在我想获取背景+用户用户绘制到变量中的内容。存在getBackGround和getForeGround,不是两者都存在。我该如何实现?我不想将图像本地存储在人员电话上。

this example使用了用于实现跟踪的代码,而setBackground是通过

实现的
  dv = new DrawingView(this);
  dv.setBackground(imageview.getDrawable());

定义了图像视图并在其中包含数据的地方。

1 个答案:

答案 0 :(得分:0)

您必须传递view(视图的名称),其中视图类似于relativeLayout

    view.setDrawingCacheEnabled(true);

    view.buildDrawingCache();

    Bitmap returnedBitmap = view.getDrawingCache();

    imageView.setImageBitmap(returnedBitmap);