2015-03-30 66 views
1

首先,我創建的應用程序需要類似於iOS中的透明活動+模糊。Android:SwipeRefreshLayout導致RecyclerView在更新截圖時沒有更新?

我決定用戶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); 

,然後做一些模糊的方法(stack blur)和新活動的設置背景是這樣

 activity.getWindow().setBackgroundDrawable(bd); 

這種方法除了當作品非常好我原來的活動包含RecyclerView。我得到的結果總是從我第一次啓動新活動時返回相同的位圖

例如,第一次活動啓動,背景圖像設置正確。但之後(第二,第三等...)背景圖像與第一個相同。

我需要幫助,對此,任何建議都會很感激,謝謝!

如果標題不好,可以自由編輯。

UPDATE ..

情侶研究這個問題的幾天後,我發現,真正的原因是SwipeRefreshLayout。第一次onRefreshListener調用後,我的截圖不會更新。

回答

0

我有同樣的問題

添加:

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

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

mSwipeLayout.setRefreshing(false);後解決了這個問題對我來說

+0

謝謝大家的幫助,我會嘗試你的方法:) 但實際上,如果避免這個問題通過使用替代庫 你也可以試試 https://github.com/liaohuqiu/android-Ultra-Pull-To-Refresh – Krit 2015-06-03 16:35:31