i have imageview. after loading bitmap in onpostexecute call setimagedrawable fill imageview ( use circleimageview) image. transitiondrawable shows 1st image , no transaction executed. how working? in advance.
private void setimagedrawable(imageview imageview, bitmap bitmap) { if (mfadeinbitmap) { bitmapdrawable drawable = null, placeholder = null; if (bitmap != null) { drawable = new bitmapdrawable(mresources, bitmap); placeholder = new bitmapdrawable(mresources, mplaceholderbitmap); } final transitiondrawable td = new transitiondrawable(new drawable[] { placeholder, drawable, }); imageview.setimagedrawable(td); td.starttransition(200); } else { imageview.setimagebitmap(bitmap); } } update: i've found solution why doesn't work me in circleimageview documentation: "using transitiondrawable circleimageview doesn't work , leads messed images."(https://github.com/hdodenhof/circleimageview).
so can suggest me way can circle image fade in animation working properly?
update 2: workaround i've found smooth transition between 2 circle images fadeout first 1 , fadein second 1 animation , post delayed runnable. here's code example.
fade_out.xml
<?xml version="1.0" encoding="utf-8"?> <set xmlns:android="http://schemas.android.com/apk/res/android" android:fillafter="true"> <alpha android:fromalpha="1.0" android:toalpha="0.0" android:duration="100" android:interpolator="@android:anim/accelerate_interpolator" /> </set> fade_in.xml identical except change fromalpha , toalpha places. after apply these animations circle image view, that:
animation anim = animationutils.loadanimation(mcontext, r.anim.fade_out); imageview.startanimation(anim); final handler handler = new handler(); handler.postdelayed(new runnable() { @override public void run() { imageview.setimagebitmap(value);//changing different image ,here set image have loaded animation anim = animationutils.loadanimation(mcontext, r.anim.fade_in); imageview.startanimation(anim); } }, 100); hope it'll helpful.
i have tried following code myself , can works , transition pretty visible:
private void setimagedrawable(imageview imageview) { bitmap bitmap1 = bitmap.createbitmap(100, 100, bitmap.config.argb_8888); bitmap bitmap2 = bitmap.createbitmap(100, 100, bitmap.config.argb_8888); new canvas(bitmap1).drawrect(0, 0, 100, 100, mwhitepaint); new canvas(bitmap2).drawrect(0, 0, 100, 100, mblackpaint); bitmapdrawable drawable1 = new bitmapdrawable(getresources(), bitmap1); bitmapdrawable drawable2 = new bitmapdrawable(getresources(), bitmap2); transitiondrawable transitiondrawable = new transitiondrawable(new drawable[] {drawable1, drawable2}); imageview.setimagedrawable(transitiondrawable); transitiondrawable.starttransition(3000); } please, check bitmap not null , it's different mplaceholderbitmap (which should not null). try setting transition duration 3 seconds, example, because maybe 200ms fast see transition itself.
Comments
Post a Comment