android - 為 AppBarLayout 設(shè)置的背景圖片 TransitionDrawable 為什么只在第一次打開的時候有效?
問題描述
預(yù)期的效果是點(diǎn)擊用戶頭像后使用 ImageRequest 下載圖片,然后給新的 Activity AppBayLayout 背景切換設(shè)置一個過渡效果,大致的實現(xiàn)代碼如下:
mQueue = CustomVolleyRequestQueue.getInstance(getApplicationContext()) .getRequestQueue();mAppBarLayout = (AppBarLayout) findViewById(R.id.app_bar_layout);ImageRequest imageRequest = new ImageRequest(mProfile.getString('profile_image_url'), new Response.Listener<Bitmap>() { @Override public void onResponse(Bitmap response) {Drawable[] drawables = new Drawable[2];drawables[0] = mAppBarLayout.getBackground();drawables[1] = new BitmapDrawable(getResources(), StackBlur.blur(response, 20, false));TransitionDrawable trans = new TransitionDrawable(drawables);mAppBarLayout.setBackground(trans);trans.startTransition(400); }}, 0, 0, null, null, null);mQueue.add(imageRequest);
現(xiàn)在遇到的問題時第一次點(diǎn)擊用戶頭像啟動用戶頁面 Activity 可以正確看到過渡效果,按返回鍵彈出之后再次點(diǎn)擊同一個用戶頭像就不再顯示過渡效果了,而是直接由 drawables[0] 變?yōu)?drawables[1]。

請問這個問題應(yīng)該怎么解決?是因為頭像圖片被緩存引起了什么問題嗎?
問題解答
回答1:會不會是因為你點(diǎn)返回鍵后 drawables[0] = mAppBarLayout.getBackground();得到的drawable就是你之前設(shè)置的TransitionDrawable
回答2:打斷點(diǎn)調(diào)試下
回答3:目測是圖片緩存,不過你可以自己先不進(jìn)行網(wǎng)絡(luò)請求下載圖片,設(shè)置個本地圖片替代網(wǎng)絡(luò)圖片進(jìn)行測試下。
回答4:動畫時間調(diào)長一點(diǎn)呢?
回答5:這上面用到的模糊類StackBlur,是開源的嗎? 求地址
相關(guān)文章:
1. javascript - immutable配合react提升性能?2. javascript - sublime快鍵鍵問題3. javascript - nodejs關(guān)于進(jìn)程間發(fā)送句柄的一點(diǎn)疑問4. Apache 已經(jīng)把網(wǎng)站根目錄的改為allow from all了,但是服務(wù)器還是不能訪問?5. 實現(xiàn)bing搜索工具urlAPI提交6. javascript - 移動端上不能實現(xiàn)拖拽布局嗎?7. vue.js - Vue 如何像Angular.js watch 一樣監(jiān)聽數(shù)據(jù)變化8. phpstudy8.1支持win11系統(tǒng)嗎?9. 配置Apache時,添加對PHP的支持時語法錯誤10. css - 寫頁面遇到個布局問題,求大佬們幫解答,在線等,急!~

網(wǎng)公網(wǎng)安備