Android 获取图形缓存不包括最近以编程方式可见的视图

Android 获取图形缓存不包括最近以编程方式可见的视图,android,android-bitmap,Android,Android Bitmap,我有一个根RelativeLayout并试图捕获整个视图,在捕获视图之前,我正在更改某些视图的可见性 我的问题是最近可见的项目不在图形缓存的位图中 顶部屏幕在位图中看起来不错,但在底部屏幕的位置有一个黑色,而不是通过编程显示的视图(llTagline)llTagline在执行此代码后在屏幕上确实可见,但在位图中不可见 我已经看到很多关于在上绘制缓存的问题,所以但是我的问题没有解决方案 这是我的密码 rlEditorParent是我的活动的根布局,它是RelativeLayout @Over

我有一个根
RelativeLayout
并试图捕获整个视图,在捕获视图之前,我正在更改某些视图的可见性

我的问题是最近可见的项目不在图形缓存的位图中

顶部屏幕在位图中看起来不错,但在底部屏幕的位置有一个黑色,而不是通过编程显示的视图(
llTagline
)<代码>llTagline在执行此代码后在屏幕上确实可见,但在位图中不可见

我已经看到很多关于在上绘制缓存的问题,所以但是我的问题没有解决方案

这是我的密码

rlEditorParent
是我的活动的根布局,它是
RelativeLayout

   @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            llBottomBar.setVisibility(View.GONE);
            llTagline.setVisibility(View.VISIBLE);
            mDrawerLayout.setVisibility(View.INVISIBLE);
            llTopBar.setVisibility(View.INVISIBLE);
            ivRemoveFinish.setVisibility(View.INVISIBLE);
            rlEditorParent.invalidate();
            rlEditorParent.setDrawingCacheEnabled(true);
            rlEditorParent.destroyDrawingCache();
            rlEditorParent.buildDrawingCache(true);
            finalBitmap = rlEditorParent.getDrawingCache(true);
        }};
我也试过了

finalBitmap = Bitmap.createBitmap(rlEditorParent.getWidth(),
                    rlEditorParent.getHeight(), Bitmap.Config.ARGB_8888);
            Canvas c = new Canvas(finalBitmap);
            rlEditorParent.layout(rlEditorParent.getLeft(),
                    rlEditorParent.getTop(), rlEditorParent.getRight(),
                    rlEditorParent.getBottom());
            rlEditorParent.draw(c);
我在应用程序中的真实屏幕是

我在finalBitmap中得到的是

试试这个


尝试此操作。

执行最后一行后,位图将循环使用。那么我如何进一步处理位图,比如将其保存到sd卡?其引发异常。然后尝试rlEditorParent.setDrawingCacheEnabled(false);生成位图而不是rlEditorParent.DestroyingDrawingCache()后;在我的回答中,再次出现异常并崩溃。你能在这里发布异常吗?好的。我在Framelayout中遇到过类似的问题,并由rlEditorParent解决。setDrawingCacheEnabled(false);生成位图后,我给了您上述解决方案,但在这里它不适用于您。因此必须查看另一个解决方案。在执行最后一行后,位图将循环使用。那么我如何进一步处理位图,比如将其保存到sd卡?其引发异常。然后尝试rlEditorParent.setDrawingCacheEnabled(false);生成位图而不是rlEditorParent.DestroyingDrawingCache()后;在我的回答中,再次出现异常并崩溃。你能在这里发布异常吗?好的。我在Framelayout中遇到过类似的问题,并由rlEditorParent解决。setDrawingCacheEnabled(false);位图生成后,我给出了上面的解决方案,但在这里它对您不起作用。因此,我们必须考虑另一种解决方案。
@Override
    public void onClick(View v) {
        // TODO Auto-generated method stub
        llBottomBar.setVisibility(View.GONE);
        llTagline.setVisibility(View.VISIBLE);
        mDrawerLayout.setVisibility(View.INVISIBLE);
        llTopBar.setVisibility(View.INVISIBLE);
        ivRemoveFinish.setVisibility(View.INVISIBLE);
        rlEditorParent.invalidate();
        rlEditorParent.setDrawingCacheEnabled(true);            
        rlEditorParent.buildDrawingCache(true);
        finalBitmap = rlEditorParent.getDrawingCache(true);
        rlEditorParent.destroyDrawingCache();
    }};