基本上,我使用辅助方法生成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;
}
此助手类中panoramaLoadingLoopDrawable
为private static
。
当我将它放入RecyclerView时,当AnimationDrawable
中有ViewHolder
项使用panoramaLoadingLoopDrawable
时,两者都会停止制作动画。
我应该{{1}}非静态还是什么?