Android的棒棒糖动画毛刺 [英] android lollipop animation glitch
问题描述
我有一个奇怪的行为与默认布局动画运行Android 5(棒棒堂)设备。我使用与被替换在运行时使用默认的片段管理多个片段的活动。当更换旧的片段,我想用动画的流畅的UI流。在pre-棒棒糖设备的动画作品像预期,但在设备上运行的是最新的操作系统,碎片毛刺的动画:
I have a strange behaviour with the default layout animation in devices running Android 5 (Lollipop). I am using an activity with multiple Fragments which are replaced at runtime using the default fragment manager. When replacing the old fragment, i want to use an animation for a smooth ui flow. On pre-lollipop devices the animation works like expected, but on devices running the latest os, the animation between fragment glitches:
我尝试使用默认的动画XML标签
I tried using the default animation xml tag
android:animateLayoutChanges="true"
由于它不工作,我把它用这个code没有影响
Because it does not work, i changed it using this code with no effect
mTransaction = mManager.beginTransaction();
mTransaction.setCustomAnimations(android.R.animator.fade_in, android.R.animator.fade_out);
mTransaction.remove(mFragment);
mTransaction.add(R.id.container, mFragment, "fragment");
mTransaction.commit();
我已经在不同的设备和Android模拟器测试code。但奇怪的是,它的工作原理是预期上运行pre-棒棒糖设备和 Android模拟器运行最新的操作系统(5.0.1)。 不过,这并不对设备一样工作的Nexus 4和Nexus 5运行Android 5.0
I have tested the code on different devices and in the android emulator. The strange thing is, that it works like expected on devices running pre-lollipop and in the android emulator running the latest OS (5.0.1). But it does not work on devices like Nexus 4 and Nexus 5 running Android 5.0
有什么建议?任何帮助吗?
Any suggestions? Any Help?
在此先感谢
编辑:
这似乎是一个错误根据使用的设备上。我已经测试了在不同设备上的code(三星Galaxy S4,HTC(一MINI2,其中M8,Desire S的),的Nexus 4和5),并且只出现在谷歌Nexus设备。
It seems to be a bug depending on the used device. I have tested the code on different devices (Samsung Galaxy S4, HTC (One mini2, One M8, Desire S), Nexus 4&5), and it only appears on google nexus devices.
修改
一个解决办法来解决这个动画的问题是通过禁用硬件加速
One Workaround to fix the animation issue is to disable the hardware acceleration via the
<应用的Android版本:hardwareAccelerated =假>
在应用程序清单标签。但是,使用这使得应用程序很慢。
tag in the app Manifest. But using this makes the app very slow.
解决方案
要解决此问题的解决方法是设置背景图片/颜色/绘制到活动中。 <一href="http://stackoverflow.com/questions/27963767/graphical-bug-while-changing-fragment-with-api-21?lq=1">see
The solution to fix this issue is to set a background image/color/drawable to the activity. see
推荐答案
设置背景
根系活力的颜色(也当不可见用户!)和图形毛刺走了。
Set the background
color of the root activity (also when not visible to the user!) and the graphical glitch is gone.
这篇关于Android的棒棒糖动画毛刺的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!