android - Animation lags on large screen sizes -
i have relativelayout
stores 5 imageview
, each of them contains image of cloud. images differ in size, smallest being 582*182 , largest being 700*400. size of area contains clouds 860*1080.
in top of screen image want load onto server , below relativelayout
described above. when user falls on screen clouds start moving. problem whole animation lagging badly (i'm trying run on htc one). animation described below:
<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>
the imageview
s described so:
<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"/>
and start below:
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);
i've checked hardware acceleration condition via mclouds[0].ishardwareaccelerated()
- it's enabled. i've tried decrease bitmap's size loading them in rgb_565
format - no luck. there can lagging?
p.s. animation of same images works without lagging on ios
version of application runs on iphone 4
.
upd.: i've noticed animations run smoothly if reduce number of clouds been animated 5 4.
this may sound crazy has saved me in similar situation:
use different animation objects different views.
in case: need 3 animrtl objects, , 2 animltr java objects. so: animltr1, animltr2, animrtl1 animrtl2, animrtl3. note don't have create more xml animation files 2 have.
try , let me know result.
edit :
there 2 other solutions worth trying on mind:
in manifest, put under application tag
android:hardwareaccelerated="true" android:largeheap="true"
Comments
Post a Comment