我正在使用https://github.com/Pkmmte/CircularImageView来获取图片循环。我想在imageView中清除图像,如果已经设置的话。没有解决方案工作建议@ How to clear an ImageView in Android?。如果您使用过CirularImageView,我该如何清除图像?
编辑 编辑
我想我可以尝试在重置图像后显示空白的灰色视图但由于这不起作用,我正在编辑问题以告诉您实际问题。
这是:
我正在使用RecyclerView向朋友们展示。我的一个朋友列表没有他的图片所以我试图显示默认的头像是SVG图像。第一次当我向下滚动到他的视图时,它显示完美。当我第二次再次回滚给他时,它会抛出StackOverFlow异常。
mDefaultUserPhoto = MrVector.inflate(
getResources(), R
.drawable.vector_default_user_photo);
}
circularIV.setImageDrawable(mDefaultUserPhoto); // This is what hits for every friend when scrolled and where the StackoverFlowException occured..
跟踪:
E/InputEventReceiver﹕ Exception dispatching input event.
D/AndroidRuntime﹕ Shutting down VM
/dalvikvm﹕ threadid=1: thread exiting with uncaught exception (group=0x41965da0)
﹕ Uncaught exception start!
java.lang.StackOverflowError
System.err﹕ at java.lang.ref.FinalizerReference.add(FinalizerReference.java:54)
System.err﹕ at android.graphics.Bitmap$BitmapFinalizer.<init>(Bitmap.java:1644)
System.err﹕ at android.graphics.Bitmap.<init>(Bitmap.java:152)
System.err﹕ at android.graphics.Bitmap.nativeCreate(Native Method)
System.err﹕ at android.graphics.Bitmap.createBitmap(Bitmap.java:903)
System.err﹕ at android.graphics.Bitmap.createBitmap(Bitmap.java:880)
System.err﹕ at android.graphics.Bitmap.createBitmap(Bitmap.java:847)
System.err﹕ at com.pkmmte.view.CircularImageView.drawableToBitmap(CircularImageView.java:327)
System.err﹕ at com.pkmmte.view.CircularImageView.invalidate(CircularImageView.java:260)
System.err﹕ at android.widget.ImageView.invalidateDrawable(ImageView.java:211)
System.err﹕ at com.pkmmte.view.CircularImageView.drawableToBitmap(CircularImageView.java:330)
System.err﹕ at com.pkmmte.view.CircularImageView.invalidate(CircularImageView.java:260)
System.err﹕ at android.widget.ImageView.invalidateDrawable(ImageView.java:211)
System.err﹕ at android.graphics.drawable.Drawable.invalidateSelf(Drawable.java:376)
System.err﹕ at android.graphics.drawable.Drawable.setBounds(Drawable.java:185)
System.err﹕ at com.pkmmte.view.CircularImageView.drawableToBitmap(CircularImageView.java:330)
System.err﹕ at com.pkmmte.view.CircularImageView.invalidate(CircularImageView.java:260)
System.err﹕ at android.widget.ImageView.invalidateDrawable(ImageView.java:211)
System.err﹕ at com.pkmmte.view.CircularImageView.drawableToBitmap(CircularImageView.java:330)
System.err﹕ at com.pkmmte.view.CircularImageView.invalidate(CircularImageView.java:260)
System.err﹕ at android.graphics.drawable.Drawable.setBounds(Drawable.java:185)
System.err﹕ at com.pkmmte.view.CircularImageView.drawableToBitmap(CircularImageView.java:330)
System.err﹕ at com.pkmmte.view.CircularImageView.invalidate(CircularImageView.java:260)
System.err﹕ at android.widget.ImageView.invalidateDrawable(ImageView.java:211)
System.err﹕ at android.graphics.drawable.Drawable.invalidateSelf(Drawable.java:376)
System.err﹕ at android.graphics.drawable.Drawable.setBounds(Drawable.java:185)
System.err﹕ at com.pkmmte.view.CircularImageView.drawableToBitmap(CircularImageView.java:330)
System.err﹕ at com.pkmmte.view.CircularImageView.invalidate(CircularImageView.java:260)
System.err﹕ at android.widget.ImageView.invalidateDrawable(ImageView.java:211)
/System.err﹕ at android.graphics.drawable.Drawable.invalidateSelf(Drawable.java:376)
/System.err﹕ at android.graphics.drawable.Drawable.setBounds(Drawable.java:185)
/System.err﹕ at com.pkmmte.view.CircularImageView.drawableToBitmap(CircularImageView.java:330)
/System.err﹕ at com.pkmmte.view.CircularImageView.invalidate(CircularImageView.java:260)
/System.err﹕ at android.widget.ImageView.invalidateDrawable(ImageView.java:211)
/System.err﹕ at android.graphics.drawable.Drawable.invalidateSelf(Drawable.java:376)
/System.err﹕ at android.graphics.drawable.Drawable.setBounds(Drawable.java:185)
/System.err﹕ at com.pkmmte.view.CircularImageView.drawableToBitmap(CircularImageView.java:330)
/System.err﹕ at com.pkmmte.view.CircularImageView.invalidate(CircularImageView.java:260)
/System.err﹕ at android.widget.ImageView.invalidateDrawable(ImageView.java:211)
/System.err﹕ at android.graphics.drawable.Drawable.invalidateSelf(Drawable.java:376)
/System.err﹕ at android.graphics.drawable.Drawable.setBounds(Drawable.java:185)
/System.err﹕ at com.pkmmte.view.CircularImageView.drawableToBitmap(CircularImageView.java:330)
/System.err﹕ at com.pkmmte.view.CircularImageView.invalidate(CircularImageView.java:260)
/System.err﹕ at android.widget.ImageView.invalidateDrawable(ImageView.java:211)
/System.err﹕ at android.graphics.drawable.Drawable.invalidateSelf(Drawable.java:376)
/System.err﹕ at android.graphics.drawable.Drawable.setBounds(Drawable.java:185)
/System.err﹕ at com.pkmmte.view.CircularImageView.drawableToBitmap(CircularImageView.java:330)
/System.err﹕ at com.pkmmte.view.CircularImageView.invalidate(CircularImageView.java:260)
/System.err﹕ at android.widget.ImageView.invalidateDrawable(ImageView.java:211)
/System.err﹕ at android.graphics.drawable.Drawable.invalidateSelf(Drawable.java:376)
/System.err﹕ at android.graphics.drawable.Drawable.setBounds(Drawable.java:185)
/System.err﹕ at com.pkmmte.view.CircularImageView.invalidate(CircularImageView.java:260)
/System.err﹕ at android.widget.ImageView.invalidateDrawable(ImageView.java:211)
/System.err﹕ at android.graphics.drawable.Drawable.invalidateSelf(Drawable.java:376)
/System.err﹕ at android.graphics.drawable.Drawable.setBounds(Drawable.java:185)
/System.err﹕ at com.pkmmte.view.CircularImageView.drawableToBitmap(CircularImageView.java:330)
/System.err﹕ at com.pkmmte.view.CircularImageView.invalidate(CircularImageView.java:260)
/System.err﹕ at android.widget.ImageView.invalidateDrawable(ImageView.java:211)
/System.err﹕ at android.graphics.drawable.Drawable.invalidateSelf(Drawable.java:376)
/System.err﹕ at android.graphics.drawable.Drawable.setBounds(Drawable.java:185)
/System.err﹕ at com.pkmmte.view.CircularImageView.drawableToBitmap(CircularImageView.java:330)
/System.err﹕ at com.pkmmte.view.CircularImageView.invalidate(CircularImageView.java:260)
/System.err﹕ at android.widget.ImageView.invalidateDrawable(ImageView.java:211)
/System.err﹕ at android.graphics.drawable.Drawable.setBounds(Drawable.java:185)
/System.err﹕ at com.pkmmte.view.CircularImageView.drawableToBitmap(CircularImageView.java:330)
/System.err﹕ at com.pkmmte.view.CircularImageView.invalidate(CircularImageView.java:260)
/System.err﹕ at android.widget.ImageView.invalidateDrawable(ImageView.java:211)
/System.err﹕ at android.graphics.drawable.Drawable.invalidateSelf(Drawable.java:376)
/System.err﹕ at android.graphics.drawable.Drawable.setBounds(Drawable.java:185)
/System.err﹕ at com.pkmmte.view.CircularImageView.drawableToBitmap(CircularImageView.java:330)
/System.err﹕ at com.pkmmte.view.CircularImageView.invalidate(CircularImageView.java:260)
/System.err﹕ at android.widget.ImageView.invalidateDrawable(ImageView.java:211)
/System.err﹕ at android.graphics.drawable.Drawable.invalidateSelf(Drawable.java:376)
/System.err﹕ at android.graphics.drawable.Drawable.setBounds(Drawable.java:185)
/System.err﹕ at com.pkmmte.view.CircularImageView.drawableToBitmap(CircularImageView.java:330)
/System.err﹕ at com.pkmmte.view.CircularImageView.invalidate(CircularImageView.java:260)
/System.err﹕ at android.widget.ImageView.invalidateDrawable(ImageView.java:211)
/System.err﹕ at android.graphics.drawable.Drawable.invalidateSelf(Drawable.java:376)
/System.err﹕ at android.graphics.drawable.Drawable.setBounds(Drawable.java:185)
/System.err﹕ at com.pkmmte.view.CircularImageView.drawableToBitmap(CircularImageView.java:330)
/System.err﹕ at com.pkmmte.view.CircularImageView.invalidate(CircularImageView.java:260)
/System.err﹕ at android.widget.ImageView.invalidateDrawable(ImageView.java:211)
/System.err﹕ at android.graphics.drawable.Drawable.invalidateSelf(Drawable.java:376)
/System.err﹕ at android.graphics.drawable.Drawable.setBounds(Drawable.java:185)
/System.err﹕ at com.pkmmte.view.CircularImageView.drawableToBitmap(CircularImageView.java:330)
/System.err﹕ at com.pkmmte.view.CircularImageView.invalidate(CircularImageView.java:260)
/System.err﹕ at android.widget.ImageView.invalidateDrawable(ImageView.java:211)
/System.err﹕ at android.graphics.drawable.Drawable.invalidateSelf(Drawable.java:376)
/System.err﹕ at android.graphics.drawable.Drawable.setBounds(Drawable.java:185)
/System.err﹕ at com.pkmmte.view.CircularImageView.drawableToBitmap(CircularImageView.java:330)
/System.err﹕ at com.pkmmte.view.CircularImageView.invalidate(CircularImageView.java:260)
/System.err﹕ at android.widget.ImageView.invalidateDrawable(ImageView.java:211)
/System.err﹕ at android.graphics.drawable.Drawable.invalidateSelf(Drawable.java:376)
/System.err﹕ at android.graphics.drawable.Drawable.setBounds(Drawable.java:185)
/System.err﹕ at com.pkmmte.view.CircularImageView.drawableToBitmap(CircularImageView.java:330)
/System.err﹕ at com.pkmmte.view.CircularImageView.invalidate(CircularImageView.java:260)
/System.err﹕ at android.widget.ImageView.invalidateDrawable(ImageView.java:211)
/System.err﹕ at android.graphics.drawable.Drawable.invalidateSelf(Drawable.java:376)
/System.err﹕ at android.graphics.drawable.Drawable.setBounds(Drawable.java:185)
/System.err﹕ at com.pkmmte.view.CircularImageView.drawableToBitmap(CircularImageView.java:330)
/System.err﹕ at com.pkmmte.view.CircularImageView.invalidate(CircularImageView.java:260)
/System.err﹕ at android.widget.ImageView.invalidateDrawable(ImageView.java:211)
/System.err﹕ at android.graphics.drawable.Drawable.invalidateSelf(Drawable.java:376)
/System.err﹕ at android.graphics.drawable.Drawable.setBounds(Drawable.java:185)
/System.err﹕ at com.pkmmte.view.CircularImageView.drawableToBitmap(CircularImageView.java:330)
/System.err﹕ at com.pkmmte.view.CircularImageView.invalidate(CircularImageView.java:260)
/System.err﹕ at android.widget.ImageView.invalidateDrawable(ImageView.java:211)
/System.err﹕ at android.graphics.drawable.Drawable.invalidateSelf(Drawable.java:376)
/System.err﹕ at android.graphics.drawable.Drawable.setBounds(Drawable.java:185)
/System.err﹕ at android.graphics.drawable.Drawable.invalidateSelf(Drawable.java:376)
/System.err﹕ at android.graphics.drawable.Drawable.setBounds(Drawable.java:185)
/System.err﹕ at com.pkmmte.view.CircularImageView.drawableToBitmap(CircularImageView.java:330)
/System.err﹕ at com.pkmmte.view.CircularImageView.invalidate(CircularImageView.java:260)
/System.err﹕ at android.widget.ImageView.invalidateDrawable(ImageView.java:211)
/System.err﹕ at android.graphics.drawable.Drawable.invalidateSelf(Drawable.java:376)
/System.err﹕ at android.graphics.drawable.Drawable.setBounds(Drawable.java:185)
/System.err﹕ at com.pkmmte.view.CircularImageView.drawableToBitmap(CircularImageView.java:330)
/System.err﹕ at com.pkmmte.view.CircularImageView.invalidate(CircularImageView.java:260)
/System.err﹕ at android.widget.ImageView.invalidateDrawable(ImageView.java:211)
/System.err﹕ at android.graphics.drawable.Drawable.invalidateSelf(Drawable.java:376)
/System.err﹕ at android.graphics.drawable.Drawable.setBounds(Drawable.java:185)
/System.err﹕ at com.pkmmte.view.CircularImageView.drawableToBitmap(CircularImageView.java:330)
/System.err﹕ at com.pkmmte.view.CircularImageView.invalidate(CircularImageView.java:260)
/System.err﹕ at android.widget.ImageView.invalidateDrawable(ImageView.java:211)
/System.err﹕ at android.graphics.drawable.Drawable.invalidateSelf(Drawable.java:376)
/System.err﹕ at android.graphics.drawable.Drawable.setBounds(Drawable.java:185)
/System.err﹕ at com.pkmmte.view.CircularImageView.invalidate(CircularImageView.java:260)
/System.err﹕ at android.widget.ImageView.invalidateDrawable(ImageView.java:211)
/System.err﹕ at android.graphics.drawable.Drawable.invalidateSelf(Drawable.java:376)
/System.err﹕ at android.graphics.drawable.Drawable.setBounds(Drawable.java:185)
/System.err﹕ at com.pkmmte.view.CircularImageView.drawableToBitmap(CircularImageView.java:330)
/System.err﹕ at com.pkmmte.view.CircularImageView.invalidate(CircularImageView.java:260)
/System.err﹕ at android.widget.ImageView.invalidateDrawable(ImageView.java:211)
/System.err﹕ at android.graphics.drawable.Drawable.invalidateSelf(Drawable.java:376)
/System.err﹕ at android.graphics.drawable.Drawable.setBounds(Drawable.java:185)
/System.err﹕ at com.pkmmte.view.CircularImageView.drawableToBitmap(CircularImageView.java:330)
/System.err﹕ at com.pkmmte.view.CircularImageView.invalidate(CircularImageView.java:260)
/System.err﹕ at android.widget.ImageView.invalidateDrawable(ImageView.java:211)
/System.err﹕ at android.graphics.drawable.Drawable.invalidateSelf(Drawable.java:376)
/System.err﹕ at android.graphics.drawable.Drawable.setBounds(Drawable.java:185)
/System.err﹕ at com.pkmmte.view.CircularImageView.drawableToBitmap(CircularImageView.java:330)
/System.err﹕ at com.pkmmte.view.CircularImageView.invalidate(CircularImageView.java:260)
/System.err﹕ at android.widget.ImageView.invalidateDrawable(ImageView.java:211)
/System.err﹕ at android.graphics.drawable.Drawable.invalidateSelf(Drawable.java:376)
/System.err﹕ at android.graphics.drawable.Drawable.setBounds(Drawable.java:185)
/System.err﹕ at com.pkmmte.view.CircularImageView.drawableToBitmap(CircularImageView.java:330)
/System.err﹕ at com.pkmmte.view.CircularImageView.invalidate(CircularImageView.java:260)
/System.err﹕ at android.widget.ImageView.invalidateDrawable(ImageView.java:211)
/System.err﹕ at android.graphics.drawable.Drawable.invalidateSelf(Drawable.java:376)
/System.err﹕ at android.graphics.drawable.Drawable.setBounds(Drawable.java:185)
/System.err﹕ at com.pkmmte.view.CircularImageView.drawableToBitmap(CircularImageView.java:330)
/System.err﹕ at com.pkmmte.view.CircularImageView.invalidate(CircularImageView.java:260)
/System.err﹕ at android.widget.ImageView.invalidateDrawable(ImageView.java:211)
/System.err﹕ at android.graphics.drawable.Drawable.invalidateSelf(Drawable.java:376)
/System.err﹕ at android.graphics.drawable.Drawable.setBounds(Drawable.java:185)
/System.err﹕ at com.pkmmte.view.CircularImageView.drawableToBitmap(CircularImageView.java:330)
/System.err﹕ at com.pkmmte.view.CircularImageView.invalidate(CircularImageView.java:260)
/System.err﹕ at android.widget.ImageView.invalidateDrawable(ImageView.java:211)
/System.err﹕ at android.graphics.drawable.Drawable.invalidateSelf(Drawable.java:376)
/System.err﹕ at android.graphics.drawable.Drawable.setBounds(Drawable.java:185)
/System.err﹕ at com.pkmmte.view.CircularImageView.drawableToBitmap(CircularImageView.java:330)
/System.err﹕ at com.pkmmte.view.CircularImageView.invalidate(CircularImageView.java:260)
/System.err﹕ at android.widget.ImageView.invalidateDrawable(ImageView.java:211)
/System.err﹕ at android.graphics.drawable.Drawable.invalidateSelf(Drawable.java:376)
/System.err﹕ at android.graphics.drawable.Drawable.setBounds(Drawable.java:185)
/System.err﹕ at com.pkmmte.view.CircularImageView.drawableToBitmap(CircularImageView.java:330)
/System.err﹕ at com.pkmmte.view.CircularImageView.invalidate(CircularImageView.java:260)
/System.err﹕ at android.widget.ImageView.invalidateDrawable(ImageView.java:211)
/System.err﹕ at android.graphics.drawable.Drawable.invalidateSelf(Drawable.java:376)
/System.err﹕ at android.graphics.drawable.Drawable.setBounds(Drawable.java:185)
/System.err﹕ at com.pkmmte.view.CircularImageView.drawableToBitmap(CircularImageView.java:330)
/System.err﹕ at com.pkmmte.view.CircularImageView.invalidate(CircularImageView.java:260)
/System.err﹕ at android.widget.ImageView.invalidateDrawable(ImageView.java:211)
/System.err﹕ at android.graphics.drawable.Drawable.invalidateSelf(Drawable.java:376)
/System.err﹕ at android.graphics.drawable.Drawable.setBounds(Drawable.java:185)
/System.err﹕ at com.pkmmte.view.CircularImageView.drawableToBitmap(CircularImageView.java:330)
/System.err﹕ at com.pkmmte.view.CircularImageView.invalidate(CircularImageView.java:260)
/System.err﹕ at android.widget.ImageView.invalidateDrawable(ImageView.java:211)
/System.err﹕ at android.graphics.drawable.Drawable.invalidateSelf(Drawable.java:376)
/System.err﹕ at android.graphics.drawable.Drawable.setBounds(Drawable.java:185) View.java:330)
/System.err﹕ at com.pkmmte.view.CircularImageView.invalidate(CircularImageView.java:260)
/System.err﹕ at android.widget.ImageView.invalidateDrawable(ImageView.java:211)
/System.err﹕ at android.graphics.drawable.Drawable.invalidateSelf(Drawable.java:376)
/System.err﹕ at android.graphics.drawable.Drawable.setBounds(Drawable.java:185)
/System.err﹕ at com.pkmmte.view.CircularImageView.drawableToBitmap(CircularImageView.java:330)
/System.err﹕ at com.pkmmte.view.CircularImageView.invalidate(CircularImageView.java:260)
/System.err﹕ at android.widget.ImageView.invalidateDrawable(ImageView.java:211)
/System.err﹕ at android.graphics.drawable.Drawable.invalidateSelf(Drawable.java:376)
/System.err﹕ at com.pkmmte.view.CircularImageView.drawableToBitmap(CircularImageView.java:330)
/System.err﹕ at com.pkmmte.view.CircularImageView.invalidate(CircularImageView.java:260)
/System.err﹕ at android.widget.ImageView.invalidateDrawable(ImageView.java:211)
/System.err﹕ at android.graphics.drawable.Drawable.invalidateSelf(Drawable.java:376)
/System.err﹕ at android.graphics.drawable.Drawable.setBounds(Drawable.java:185)
/System.err﹕ at com.pkmmte.view.CircularImageView.drawableToBitmap(CircularImageView.java:330)
/System.err﹕ at com.pkmmte.view.CircularImageView.invalidate(CircularImageView.java:260)
/System.err﹕ at android.widget.ImageView.invalidateDrawable(ImageView.java:211)
/System.err﹕ at android.graphics.drawable.Drawable.invalidateSelf(Drawable.java:376)
/System.err﹕ at android.graphics.drawable.Drawable.setBounds(Drawable.java:185)
/System.err﹕ at com.pkmmte.view.CircularImageView.drawableToBitmap(CircularImageView.java:330)
/System.err﹕ at com.pkmmte.view.CircularImageView.invalidate(CircularImageView.java:260)
/System.err﹕ at android.widget.ImageView.invalidateDrawable(ImageView.java:211)
/System.err﹕ at android.graphics.drawable.Drawable.invalidateSelf(Drawable.java:376)
/System.err﹕ at android.graphics.drawable.Drawable.setBounds(Drawable.java:185)
/System.err﹕ at com.pkmmte.view.CircularImageView.drawableToBitmap(CircularImageView.java:330)
/System.err﹕ at com.pkmmte.view.CircularImageView.invalidate(CircularImageView.java:260)
/System.err﹕ at android.widget.ImageView.invalidateDrawable(ImageView.java:211)
/System.err﹕ at android.graphics.drawable.Drawable.invalidateSelf(Drawable.java:376)
/System.err﹕ at android.graphics.drawable.Drawable.setBounds(Drawable.java:185)
/System.err﹕ at com.pkmmte.view.CircularImageView.drawableToBitmap(CircularImageView.java:330)
/System.err﹕ at com.pkmmte.view.CircularImageView.invalidate(CircularImageView.java:260)
/System.err﹕ at android.widget.ImageView.invalidateDrawable(ImageView.java:211)
/System.err﹕ at android.graphics.drawable.Drawable.invalidateSelf(Drawable.java:376)
/System.err﹕ at android.graphics.drawable.Drawable.setBounds(Drawable.java:185)
/System.err﹕ at com.pkmmte.view.CircularImageView.drawableToBitmap(CircularImageView.java:330)
/System.err﹕ at com.pkmmte.view.CircularImageView.invalidate(CircularImageView.java:260)
/System.err﹕ at android.widget.ImageView.invalidateDrawable(ImageView.java:211)
/System.err﹕ at android.graphics.drawable.Drawable.invalidateSelf(Drawable.java:376)
/System.err﹕ at android.graphics.drawable.Drawable.setBounds(Drawable.java:185)
/System.err﹕ at com.pkmmte.view.CircularImageView.drawableToBitmap(CircularImageView.java:330)
/System.err﹕ at com.pkmmte.view.CircularImageView.invalidate(CircularImageView.java:260)
/System.err﹕ at android.widget.ImageView.invalidateDrawable(ImageView.java:211)
/System.err﹕ at android.graphics.drawable.Drawable.invalidateSelf(Drawable.java:376)
/System.err﹕ at android.graphics.drawable.Drawable.setBounds(Drawable.java:185)
/System.err﹕ at com.pkmmte.view.CircularImageView.drawableToBitmap(CircularImageView.java:330)
/System.err﹕ at com.pkmmte.view.CircularImageView.invalidate(CircularImageView.java:260)
/System.err﹕ at android.widget.ImageView.invalidateDrawable(ImageView.java:211)
/System.err﹕ at android.graphics.drawable.Drawable.invalidateSelf(Drawable.java:376)
/System.err﹕ at android.graphics.drawable.Drawable.setBounds(Drawable.java:185)
/System.err﹕ at com.pkmmte.view.CircularImageView.drawableToBitmap(CircularImageView.java:330)
/System.err﹕ at com.pkmmte.view.CircularImageView.invalidate(CircularImageView.java:260)
/System.err﹕ at android.widget.ImageView.invalidateDrawable(ImageView.java:211)
/System.err﹕ at android.graphics.drawable.Drawable.invalidateSelf(Drawable.java:376)
/System.err﹕ at android.graphics.drawable.Drawable.setBounds(Drawable.java:185)
/System.err﹕ at com.pkmmte.view.CircularImageView.drawableToBitmap(CircularImageView.java:330)
/System.err﹕ at com.pkmmte.view.CircularImageView.invalidate(CircularImageView.java:260)
/System.err﹕ at android.widget.ImageView.invalidateDrawable(ImageView.java:211)
/System.err﹕ at android.graphics.drawable.Drawable.invalidateSelf(Drawable.java:376)
/System.err﹕ at android.graphics.drawable.Drawable.setBounds(Drawable.java:185)
/System.err﹕ at com.pkmmte.view.CircularImageView.drawableToBitmap(CircularImageView.java:330)
/System.err﹕ at com.pkmmte.view.CircularImageView.invalidate(CircularImageView.java:260)
/System.err﹕ at android.widget.ImageView.invalidateDrawable(ImageView.java:211)
/System.err﹕ at android.graphics.drawable.Drawable.invalidateSelf(Drawable.java:376)
/System.err﹕ at android.graphics.drawable.Drawable.setBounds(Drawable.java:185)
/System.err﹕ at com.pkmmte.view.CircularImageView.drawableToBitmap(CircularImageView.java:330)
/System.err﹕ at com.pkmmte.view.CircularImageView.invalidate(CircularImageView.java:260)
/System.err﹕ at android.widget.ImageView.invalidateDrawable(ImageView.java:211)
/System.err﹕ at android.graphics.drawable.Drawable.invalidateSelf(Drawable.java:376)
/System.err﹕ at android.graphics.drawable.Drawable.setBounds(Drawable.java:185)
/System.err﹕ at com.pkmmte.view.CircularImageView.drawableToBitmap(CircularImageView.java:330)
/System.err﹕ at com.pkmmte.view.CircularImageView.invalidate(CircularImageView.java:260)
/System.err﹕ at android.widget.ImageView.invalidateDrawable(ImageView.java:211)
/System.err﹕ at android.graphics.drawable.Drawable.invalidateSelf(Drawable.java:376)
/System.err﹕ at android.graphics.drawable.Drawable.setBounds(Drawable.java:185)
/System.err﹕ at com.pkmmte.view.CircularImageView.drawableToBitmap(CircularImageView.java:330)
/System.err﹕ at com.pkmmte.view.CircularImageView.invalidate(CircularImageView.java:260)
/System.err﹕ at android.widget.ImageView.invalidateDrawable(ImageView.java:211)
/System.err﹕ at android.graphics.drawable.Drawable.invalidateSelf(Drawable.java:376)
/System.err﹕ at android.graphics.drawable.Drawable.setBounds(Drawable.java:185)
/System.err﹕ at com.pkmmte.view.CircularImageView.drawableToBitmap(CircularImageView.java:330)
/System.err﹕ at com.pkmmte.view.CircularImageView.invalidate(CircularImageView.java:260)
/System.err﹕ at android.widget.ImageView.invalidateDrawable(ImageView.java:211)
/System.err﹕ at android.graphics.drawable.Drawable.invalidateSelf(Drawable.java:376)
/System.err﹕ at android.graphics.drawable.Drawable.setBounds(Drawable.java:185)
/System.err﹕ at com.pkmmte.view.CircularImageView.drawableToBitmap(CircularImageView.java:330)
/System.err﹕ at com.pkmmte.view.CircularImageView.invalidate(CircularImageView.java:260)
/System.err﹕ at android.widget.ImageView.invalidateDrawable(ImageView.java:211)
/System.err﹕ at android.graphics.drawable.Drawable.invalidateSelf(Drawable.java:376)
/System.err﹕ at android.graphics.drawable.Drawable.setBounds(Drawable.java:185)
/System.err﹕ at com.pkmmte.view.CircularImageView.drawableToBitmap(CircularImageView.java:330)
/System.err﹕ at com.pkmmte.view.CircularImageView.invalidate(CircularImageView.java:260)
/System.err﹕ at android.widget.ImageView.invalidateDrawable(ImageView.java:211)
/System.err﹕ at android.graphics.drawable.Drawable.invalidateSelf(Drawable.java:376)
/System.err﹕ at android.graphics.drawable.Drawable.setBounds(Drawable.java:185)
/System.err﹕ at com.pkmmte.view.CircularImageView.drawableToBitmap(CircularImageView.java:330)
/System.err﹕ at com.pkmmte.view.CircularImageView.invalidate(CircularImageView.java:260)
/System.err﹕ at android.widget.ImageView.invalidateDrawable(ImageView.java:211)
/System.err﹕ at android.graphics.drawable.Drawable.invalidateSelf(Drawable.java:376)
/System.err﹕ at android.graphics.drawable.Drawable.setBounds(Drawable.java:185)
/System.err﹕ at com.pkmmte.view.CircularImageView.drawableToBitmap(CircularImageView.java:330)
/System.err﹕ at com.pkmmte.view.CircularImageView.invalidate(CircularImageView.java:260)
/System.err﹕ at android.widget.ImageView.invalidateDrawable(ImageView.java:211)
/System.err﹕ at android.graphics.drawable.Drawable.invalidateSelf(Drawable.java:376)
/System.err﹕ at android.graphics.drawable.Drawable.setBounds(Drawable.java:185)
/System.err﹕ at com.pkmmte.view.CircularImageView.drawableToBitmap(CircularImageView.java:330)
/System.err﹕ at com.pkmmte.view.CircularImageView.invalidate(CircularImageView.java:260)
/System.err﹕ at android.widget.ImageView.invalidateDrawable(ImageView.java:211)
/System.err﹕ at android.graphics.drawable.Drawable.invalidateSelf(Drawable.java:376)
/System.err﹕ at android.graphics.drawable.Drawable.setBounds(Drawable.java:185)
/System.err﹕ at com.pkmmte.view.CircularImageView.drawableToBitmap(CircularImageView.java:330)
/System.err﹕ at com.pkmmte.view.CircularImageView.invalidate(CircularImageView.java:260)
/System.err﹕ at android.widget.ImageView.invalidateDrawable(ImageView.java:211)
/System.err﹕ at android.graphics.drawable.Drawable.invalidateSelf(Drawable.java:376)
/System.err﹕ at android.graphics.drawable.Drawable.setBounds(Drawable.java:185)
/System.err﹕ at android.widget.ImageView.configureBounds(ImageView.java:956)
/System.err﹕ at android.widget.ImageView.updateDrawable(ImageView.java:738)
/System.err﹕ at android.widget.ImageView.setImageDrawable(ImageView.java:431)
/System.err﹕ at com.app.friends..adapters.FriendsAdapter.setPicture(FriendsAdapter.java:175)
/System.err﹕ at com.app.friends..adapters.FriendsAdapter.onBindViewHolder(FriendsAdapter.java:124)
答案 0 :(得分:0)
试试这个:
boolean checkDrawable = (ImageView.getDrawable() != null);
if(checkDrawable ) {
// imageView has image
}
else {
// no image assigned in image view
}
答案 1 :(得分:0)
尝试使用以下内容,
imageview.setImageResource(0);
或
imageView.setBackground(null);
答案 2 :(得分:0)
建议的方法不起作用,因为您可以在CircleImageView
的来源中看到开发人员对Bitmap
中设置的onDraw
进行了验证:
@Override
public void onDraw(Canvas canvas) {
// Don't draw anything without an image
if(image == null)
return;
...
...
}
因此,这意味着如果将null
设置为位图,则不会执行此方法,并且仍将绘制旧位图。我的建议只是隐藏视图,使用circleImageView.setVisibility(View.GONE);
或circleImageView.setVisibility(View.INVISIBLE)
;如果您希望视图占用布局建议的空间。
答案 3 :(得分:0)
try this..
class RoundedImageView extends ImageView {
public RoundedImageView(Context context) {
super(context);
}
public ChimmerRoundedImageView(Context context, AttributeSet attrs) {
super(context, attrs);
}
public ChimmerRoundedImageView(Context context, AttributeSet attrs,
int defStyle) {
super(context, attrs, defStyle);
}
@Override
protected void onDraw(Canvas canvas) {
float radius = 90.0f; // angle of round corners
Path clipPath = new Path();
RectF rect = new RectF(0, 0, this.getWidth(), this.getHeight());
clipPath.addRoundRect(rect, radius, radius, Path.Direction.CW);
canvas.clipPath(clipPath);
super.onDraw(canvas);
}
}
答案 4 :(得分:0)
如果您的位图为空,则在onBindViewHolder()
的{{1}}中创建一个包含空图片或默认图片的位图,然后将其设置为RecyclerView.Adapter
CircularImageVeiw
答案 5 :(得分:0)
我找不到如何在CircularImageView中清除图像的方法,但可以找到StackOverflowException的原因。我使用Picasso作为缓存库,“不清除”缓存。所以转移到UniversalImageLoader,它工作正常,没有OutOfMemoryException或StackOverflowException。
如果你想坚持使用Picasso,那么你可能想要添加代码来清除缓存。这个linke有帮助 - &gt; Clear Cache memory of Picasso