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.
The reason why this glitch occurs is because
WebView extends AbsoluteLayout
. By defaultViewGroup
s 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 theWebView
, you will need to callwebView.setTransitionGroup(true)
(or set the attribute in XML usingandroid:transitionGroup="true"
). This should cause theWebView
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 theWebView
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.