Weird issue when transitioning ImageView in Android 5.0 -



Weird issue when transitioning ImageView in Android 5.0 -

i'm experiencing unusual issue / bug regarding imageview transitions between activities in android 5.0.

i'm trying transition thumbnail image fragment a (in activity a) header image of fragment b (in activity b). works of time, messes ever slightly.

here's image of looks when messes up:

naturally, it's supposed fill entire area. both imageviews set scaletype.center_crop, can't imagine beingness issue.

what's curious issue fixes upon scrolling in activity b (everything contained within subclassed scrollview changes imageview padding upon scrolling).

the code launching activity b pretty simple:

activityoptionscompat options = activityoptionscompat.makescenetransitionanimation( activity, thumbimageview, "cover"); // "cover" shared element name both imageviews activitycompat.startactivity(activity, intent, options.tobundle());

here's code observable scrollview listener:

scrollview.setonscrollchangedlistener(new onscrollchangedlistener() { @override public void onscrollchanged(scrollview who, int l, int t, int oldl, int oldt) { // such parallax, much wow headerimageview.setpadding(0, (int) (t / 1.5), 0, 0); } });

also, here's part of theme style:

<item name="android:windowcontenttransitions">true</item> <item name="android:windowallowentertransitionoverlap">true</item> <item name="android:windowallowreturntransitionoverlap">true</item> <item name="android:windowsharedelemententertransition">@android:transition/move</item> <item name="android:windowsharedelementexittransition">@android:transition/move</item>

any ideas?

try adding next code fragment b's oncreateview() method:

getactivity().postponeentertransition(); scrollview.getviewtreeobserver().addonpredrawlistener(new viewtreeobserver.onpredrawlistener() { public boolean onpredraw() { scrollview.getviewtreeobserver().removeonpredrawlistener(this); getactivity().startpostponedentertransition(); homecoming true; } });

does problem still occur when code present? ensure transition begins after fragment has finished layout.

you might need phone call startpostponedentertransition() later this... example, if loading high resolution image in sec activity, seek calling startpostponedentertransition after image has been loaded (i.e. set onpredraw listener on imageview instead of on window's decor view).

android android-5.0-lollipop shared-element-transition activity-transition

Comments

Popular posts from this blog

xslt - DocBook 5 to PDF transform failing with error: "fo:flow" is missing child elements. Required content model: marker* -

mediawiki - How do I insert tables inside infoboxes on Wikia pages? -

SQL Server : need assitance parsing delimted data and returning a long concatenated string -