RecyclerViews和AnimationDrawables - 如何在不停止在窗口中显示另一个视图的情况下将AnimationDrawables放入ViewHolder中?

时间:2017-12-21 04:57:10

标签: android animationdrawable

基本上,我使用辅助方法生成AnimationDrawable

public static AnimationDrawable requestLoadingDrawable(Context originContext) {
        if(panoramaLoadingLoopDrawable == null) {
            panoramaLoadingLoopDrawable = new AnimationDrawable();
            Bitmap src = BitmapFactory.decodeResource(originContext.getResources(), R.drawable.load360_3lines);
            BitmapDrawable frameInDrawable;
            //int squareInstDim = (int)(200*adapterCtx.getResources().getDisplayMetrics().density);
            int horiDim = (int)(src.getWidth() / 10);
            int vertDim = (int)(src.getHeight() / 3);
            Bitmap frame;
            for(int i = 0; i < 3; i++) {
                for(int j = 0; j < 10; j++) {
                    frame = Bitmap.createBitmap(src, j * horiDim, i*vertDim, horiDim, vertDim);
                    frameInDrawable = new BitmapDrawable(originContext.getResources(), frame);
                    panoramaLoadingLoopDrawable.addFrame(frameInDrawable, (1000/30));
                }
            }
            src.recycle();
        }
        panoramaLoadingLoopDrawable.setOneShot(false);
        return panoramaLoadingLoopDrawable;
    }

此助手类中panoramaLoadingLoopDrawableprivate static

当我将它放入RecyclerView时,当AnimationDrawable中有ViewHolder项使用panoramaLoadingLoopDrawable时,两者都会停止制作动画。

我应该{{1}}非静态还是什么?

0 个答案:

没有答案