【发布时间】:2015-11-06 00:01:18
【问题描述】:
我有一个RelativeLayout,其中存储了五个ImageView,每个都包含一个云图像。所有图像的大小都不同,最小的为 582*182,最大的为 700*400。包含云的区域大小为860*1080。
屏幕顶部是我要加载到服务器上的图像,下面是上面描述的RelativeLayout。当用户落在那个屏幕上时,云开始移动。问题是整个动画严重滞后(我试图在 HTC One 上运行它)。
我的动画描述如下:
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/linear_interpolator"
android:fillEnabled="true"
android:fillAfter="true">
<translate xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="12000"
android:toXDelta="-12%p"
android:repeatCount="infinite"
android:repeatMode="reverse"/>
</set>
ImageViews 是这样描述的:
<ImageView
android:id="@+id/clouds_image_view_cloud2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="cloud 2"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"/>
我开始如下:
Animation animRToL = AnimationUtils.loadAnimation(mContext, R.anim.right_to_left);
Animation animLToR = AnimationUtils.loadAnimation(mContext, R.anim.left_to_right);
mClouds[0].startAnimation(animRToL);
mClouds[2].startAnimation(animRToL);
mClouds[1].startAnimation(animLToR);
mClouds[3].startAnimation(animLToR);
mClouds[4].startAnimation(animRToL);
我已经通过mClouds[0].isHardwareAccelerated() 检查了硬件加速条件 - 它已启用。我试图通过以RGB_565 格式加载它们来减小位图的大小 - 不走运。对于这种滞后,我能做些什么吗?
P.S. 相同图像的动画在iOS 运行在iPhone 4 上的应用程序版本没有任何滞后。
更新:我注意到如果我将动画云的数量从 5 个减少到 4 个,动画会运行顺利。
【问题讨论】:
-
您找到解决方案了吗?我遇到过类似的情况。
-
@Jerome 很遗憾没有,我们决定不在 android 上使用这样的动画。
标签: android lag translate-animation