简体   繁体   English

Android:SwipeRefreshLayout导致RecyclerView不能在截屏时更新?

[英]Android: SwipeRefreshLayout cause RecyclerView not update when take screenshot?

First, I am creating an app the need to something like transparent activity + blur like in iOS. 首先,我要创建一个需要透明活动+在iOS中模糊的应用程序。

I decided to user getDrawingcache of an entire window 我决定使用整个窗口的getDrawingcache用户

        View decorView = activity.getWindow().getDecorView();
        decorView.setDrawingCacheQuality(View.DRAWING_CACHE_QUALITY_LOW);
        decorView.setDrawingCacheEnabled(true);
        decorView.buildDrawingCache();
        image = Bitmap.createBitmap(decorView.getDrawingCache());
        decorView.destroyDrawingCache();
        decorView.setDrawingCacheEnabled(false);

and then do some blur method (stack blur) and set background of new activity like this 然后执行一些模糊方法(堆栈模糊)并像这样设置新活动的背景

        activity.getWindow().setBackgroundDrawable(bd);

This approach is works very good except when my original activity contains RecyclerView . 除了当我的原始活动包含RecyclerView时,这种方法非常有效。 The result i got is always return the same bitmap from first time I launched new activity 我得到的结果总是从我第一次启动新活动时返回相同的位图

eg. 例如。 First time activity launched, background image set correctly. 首次启动活动,背景图片设置正确。 But after that (2nd, 3rd and so on... ) background image is the same as first one. 但是之后(第二,第三等)背景图像与第一个相同。

I need help for this, any suggestion will be much appreciate, Thank you!! 我需要帮助,任何建议将不胜感激,谢谢!!

If the title is not good, you can edit it freely. 如果标题不好,则可以自由编辑。

UPDATE.. UPDATE ..

after couple of days of investigate this issue, I found out that real cause is SwipeRefreshLayout. 经过几天的调查此问题,我发现真正的原因是SwipeRefreshLayout。 My my screenshot won't update after the first time onRefreshListener called. 我的屏幕快照在第一次调用onRefreshListener之后将不会更新。

I had the same problem 我有同样的问题

Adding: 添加:

        mRecyclerView.postDelayed(new Runnable()
        {
            @Override
            public void run()
            {
                mRecyclerView.layout(0,0,mRecyclerView.getWidth(),mRecyclerView.getHeight());

                if (mRecyclerView.isDrawingCacheEnabled())
                {
                    mRecyclerView.destroyDrawingCache();
                }
            }
        },50);

after mSwipeLayout.setRefreshing(false); mSwipeLayout.setRefreshing(false); solved the problem for me 为我解决了问题

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM