Saturday, 4 April 2015

Round Corner image exception



when i want to use Round-corner image library from github ( like : this ) it throws an exception , I use this Project from android developer site I just in it's Xml file chang QuickContactBadge to CircularImage and then in Circular library class it throws following exception :



Process: chaapaarim.takinsoft.ir.chaapar, PID: 23756
java.lang.ClassCastException: android.graphics.drawable.TransitionDrawable cannot be cast to android.graphics.drawable.BitmapDrawable
at ir.takinsoft.chaapaar.im.ui.helper.RoundedImageView.onDraw(RoundedImageView.java:65)


does any body knows what's the reason ? and how can I solve this ?


Here is my XML :



<ir.takinsoft.chaapaar.im.ui.helper.RoundedImageView
android:id="@android:id/icon"
android:layout_height="?android:attr/listPreferredItemHeight"
android:layout_width="?android:attr/listPreferredItemHeight"
android:scaleType="centerCrop"
android:src="@drawable/ic_contact_picture_holo_light"
/>


And here is Google Sample



<QuickContactBadge android:id="@android:id/icon"
android:layout_height="?android:attr/listPreferredItemHeight"
android:layout_width="?android:attr/listPreferredItemHeight"
android:scaleType="centerCrop"
style="@style/quickContactBadgeStyle"
android:src="@drawable/ic_contact_picture_holo_light"/>


And here is function which throws exception :



@Override
protected void onDraw(Canvas canvas) {
if (((BitmapDrawable) getDrawable()) != null) {
mBitmap = ((BitmapDrawable) getDrawable()).getBitmap();
mBitmapShader = new BitmapShader(mBitmap, Shader.TileMode.CLAMP, Shader.TileMode.CLAMP);
}

paint.setAntiAlias(true);
paint.setShader(mBitmapShader);

mRoundRectShape.resize(getWidth(), getHeight());
mRoundRectShape.draw(canvas, paint);
}

No comments:

Post a Comment