android - 為 AppBarLayout 設(shè)置的背景圖片 TransitionDrawable 為什么只在第一次打開的時(shí)候有效?
問題描述
預(yù)期的效果是點(diǎn)擊用戶頭像后使用 ImageRequest 下載圖片,然后給新的 Activity AppBayLayout 背景切換設(shè)置一個過渡效果,大致的實(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)在遇到的問題時(shí)第一次點(diǎn)擊用戶頭像啟動用戶頁面 Activity 可以正確看到過渡效果,按返回鍵彈出之后再次點(diǎn)擊同一個用戶頭像就不再顯示過渡效果了,而是直接由 drawables[0] 變?yōu)?drawables[1]。

請問這個問題應(yīng)該怎么解決?是因?yàn)轭^像圖片被緩存引起了什么問題嗎?
問題解答
回答1:會不會是因?yàn)槟泓c(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:動畫時(shí)間調(diào)長一點(diǎn)呢?
回答5:這上面用到的模糊類StackBlur,是開源的嗎? 求地址
相關(guān)文章:
1. javascript - mongodb怎么設(shè)置用戶的賬戶不重復(fù)?2. python 字符串匹配問題3. 請問各位java自帶類的一些問題4. javascript - RN項(xiàng)目iOS端真機(jī)測試賬號無法登錄!5. redis sentinel怎么跑守護(hù)進(jìn)程以及日志記錄位置的?6. css - transition 的使用?7. html - angular項(xiàng)目中如何讓外鏈網(wǎng)頁在本項(xiàng)目中展示?8. 使用git管理webpack的代碼時(shí)多人怎么協(xié)作?一般托管哪些文件?9. 請問PHPstudy中的數(shù)據(jù)庫如何創(chuàng)建索引10. Python異常退出時(shí)保存進(jìn)度?

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