Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Webview glitches in shared element transition on lollipop

I've just started to rebuild my app for Android 5.0, using the appcompat support library. I've just finished implementing a transition featuring shared elements. It seems to work well, untill I add a webview.

I've made a video to demonstrate the glitch. https://www.youtube.com/watch?v=MuuGZc0Vwow

As you can see, all's fine when I open the activity. When I close it, the glitch occurs. As you can see all elements fade out like they should, except for the webview. Which just hangs there until the animation is over, kinda ruining the entire smoothness of the animation.

How do I fix this? If it could be related to the way I've set things up I'd be happy to share some code.

Thanks in advance.

like image 558
Vic V Avatar asked Dec 05 '14 13:12

Vic V


1 Answers

The reason why this glitch occurs is because WebView extends AbsoluteLayout. By default ViewGroups that are not "transition group"s and that have no background drawable will not be animated by the activity's window content transition. In order to fix the glitch with the WebView, you will need to call webView.setTransitionGroup(true) (or set the attribute in XML using android:transitionGroup="true"). This should cause the WebView to fade away as part of the activity transition instead of simply sitting there until being abruptly removed at the end of the transition.

As for the "Unable to create layer for WebView" error you are receiving, I imagine that is because the transition framework automatically creates a hardware layer for the WebView during the transition and for some reason the framework is crashing when it is trying to create the layer. This sounds like a totally separate issue related to Android's internal graphic pipeline though... I'm not sure I can give you a good answer about why the crash occurs without more information.

This issue is also discussed in the bottom of this blog post.

like image 200
Alex Lockwood Avatar answered Nov 15 '22 04:11

Alex Lockwood