在android中,如何从自定义曲面视图获取屏幕截图或位图

在android中,如何从自定义曲面视图获取屏幕截图或位图,android,Android,我正在创建android应用程序,我需要从包含imageview的框架布局中获取位图,第二个是自定义表面视图。xml文件如下所示,但当我尝试从框架布局中缩短屏幕时,我只得到下面图像的位图,而不是上面图像的位图。有人能告诉我如何获得所有框架布局的位图吗 <LinearLayout android:id="@+id/linear" android:layout_width="wrap_content" android:layout_height="wrap_conten

我正在创建android应用程序,我需要从包含imageview的框架布局中获取位图,第二个是自定义表面视图。xml文件如下所示,但当我尝试从框架布局中缩短屏幕时,我只得到下面图像的位图,而不是上面图像的位图。有人能告诉我如何获得所有框架布局的位图吗

<LinearLayout
    android:id="@+id/linear"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center|center_horizontal"
    android:layout_marginLeft="20dp"
    android:layout_marginRight="20dp"
    android:layout_marginTop="10dp"
    android:orientation="horizontal" >

    <FrameLayout
        android:id="@+id/frame"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" >

        <FrameLayout
            android:id="@+id/frmQueue"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" >

            <ImageView
                android:id="@+id/imglow"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:contentDescription="@string/app_name"
                android:scaleType="centerCrop" />

            <com.winsontan520.WScratchView
            android:id="@+id/scratch_view"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"/>

        </FrameLayout>
    </FrameLayout>
</LinearLayout>

你能试试这段代码吗

 public Bitmap loadBitmapFromView(View v, int width, int height) {
    Bitmap b = Bitmap.createBitmap(width , height, Bitmap.Config.ARGB_8888);
    Canvas c = new Canvas(b);
    v.layout(0, 0, v.getLayoutParams().width, v.getLayoutParams().height);
    v.draw(c);
    return b;
}
这个电话大概是这样的

Bitmap imageBitmap = loadBitmapFromView(frameLayout, frameLayout.getLayoutParams().width,frameLayout.getLayoutParams().height));
您可以将此代码用于FrameLayout吗

    FrameLayout view = (FrameLayout)findViewById(R.id.framelayout);
    view.setDrawingCacheEnabled(true);
    view.buildDrawingCache();
    Bitmap bm = view.getDrawingCache();

你能试试这段代码吗

 public Bitmap loadBitmapFromView(View v, int width, int height) {
    Bitmap b = Bitmap.createBitmap(width , height, Bitmap.Config.ARGB_8888);
    Canvas c = new Canvas(b);
    v.layout(0, 0, v.getLayoutParams().width, v.getLayoutParams().height);
    v.draw(c);
    return b;
}
这个电话大概是这样的

Bitmap imageBitmap = loadBitmapFromView(frameLayout, frameLayout.getLayoutParams().width,frameLayout.getLayoutParams().height));
您可以将此代码用于FrameLayout吗

    FrameLayout view = (FrameLayout)findViewById(R.id.framelayout);
    view.setDrawingCacheEnabled(true);
    view.buildDrawingCache();
    Bitmap bm = view.getDrawingCache();

我试过这一个,但它仍然给我只有图像低位图。我不是从零开始获取位图\u image我想从framlayout获取整个位图,但我仍然无法做到这一点我无法从头开始创建项目您还有其他地方可以共享代码吗,如粘贴箱的要点?因此,我可以直接查看problecm,而不是对所有内容进行编码…我的问题是,当我尝试从fram布局中获取位图时,我得到的是唯一图像视图的位图,即imagelow,在imagelow的顶部有自定义曲面视图,我在该自定义曲面视图中加载图像,并对曲面视图进行一些绘图操作。现在,在完成操作后,我需要得到fram布局侧面的完整图像。但当我试图得到位图时,我只得到imagelow的位图。否则,若我使用WScrathch视图来获取位图,那个么我只能在执行操作的图像上获取。虽然我需要这两个图像的组合位图是的,我尝试了这段代码,但它也给我的情人图像位图只。我认为问题在于自定义曲面视图没有进入框架布局内部。我不能解决它。我第一次尝试了这个代码。但它并没有给出结果。我试过这个,但它仍然给我只有图像低的位图。我不是从零开始获取位图\u image我想从framlayout获取整个位图,但我仍然无法做到这一点我无法从头开始创建项目您还有其他地方可以共享代码吗,如粘贴箱的要点?因此,我可以直接查看problecm,而不是对所有内容进行编码…我的问题是,当我尝试从fram布局中获取位图时,我得到的是唯一图像视图的位图,即imagelow,在imagelow的顶部有自定义曲面视图,我在该自定义曲面视图中加载图像,并对曲面视图进行一些绘图操作。现在,在完成操作后,我需要得到fram布局侧面的完整图像。但当我试图得到位图时,我只得到imagelow的位图。否则,若我使用WScrathch视图来获取位图,那个么我只能在执行操作的图像上获取。虽然我需要这两个图像的组合位图是的,我尝试了这段代码,但它也给我的情人图像位图只。我认为问题在于自定义曲面视图没有进入框架布局内部。我不能解决它。我第一次尝试了这个代码。但它并没有给出结果。可能的重复