如何在android中使用帧动画(how to use frame animation in android)

编程入门 行业动态 更新时间:2024-10-24 22:21:57
如何在android中使用帧动画(how to use frame animation in android)

嗨我相当新的Android我有一个活动使用帧动画,但每次强制关闭。 这是logcat

12-16 19:22:38.045 28183-28183/com.martinsapp.socialstories E/dalvikvm-heap﹕ Out of memory on a 13271056-byte allocation. 12-16 19:22:38.055 28183-28183/com.martinsapp.socialstories E/AndroidRuntime﹕ FATAL EXCEPTION: main java.lang.RuntimeException: Unable to start activity ComponentInfo{com.martinsapp.socialstories/com.martinsapp.socialstories.duckActivity}: android.view.InflateException: Binary XML file line #9: Error inflating class <unknown> at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2224) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2274) at android.app.ActivityThread.access$600(ActivityThread.java:150) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1276) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:213) at android.app.ActivityThread.main(ActivityThread.java:5153) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:511) at

这只是说图像太大了吗?

@weston是的我这是我正在使用的drawable.xml文件

<animation-list android:id="@+id/movingduck" xmlns:android="http://schemas.android.com/apk/res/android"> <item android:drawable="@drawable/movingduck1" android:duration="250"/> <item android:drawable="@drawable/movingduck2" android:duration="250"/> <item android:drawable="@drawable/movingduck3" android:duration="250"/> <item android:drawable="@drawable/movingduck4" android:duration="250"/> <item android:drawable="@drawable/movingduck5" android:duration="250"/> <item android:drawable="@drawable/movingduck6" android:duration="250"/> <item android:drawable="@drawable/movingduck7" android:duration="250"/> <item android:drawable="@drawable/movingduck8" android:duration="250"/>

hi im fairly new to android i have an activity using a frame animation but everytime it force closes. this is the logcat

12-16 19:22:38.045 28183-28183/com.martinsapp.socialstories E/dalvikvm-heap﹕ Out of memory on a 13271056-byte allocation. 12-16 19:22:38.055 28183-28183/com.martinsapp.socialstories E/AndroidRuntime﹕ FATAL EXCEPTION: main java.lang.RuntimeException: Unable to start activity ComponentInfo{com.martinsapp.socialstories/com.martinsapp.socialstories.duckActivity}: android.view.InflateException: Binary XML file line #9: Error inflating class <unknown> at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2224) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2274) at android.app.ActivityThread.access$600(ActivityThread.java:150) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1276) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:213) at android.app.ActivityThread.main(ActivityThread.java:5153) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:511) at

is this just saying the images are too big?

@weston yes i am this is the drawable.xml file im using

<animation-list android:id="@+id/movingduck" xmlns:android="http://schemas.android.com/apk/res/android"> <item android:drawable="@drawable/movingduck1" android:duration="250"/> <item android:drawable="@drawable/movingduck2" android:duration="250"/> <item android:drawable="@drawable/movingduck3" android:duration="250"/> <item android:drawable="@drawable/movingduck4" android:duration="250"/> <item android:drawable="@drawable/movingduck5" android:duration="250"/> <item android:drawable="@drawable/movingduck6" android:duration="250"/> <item android:drawable="@drawable/movingduck7" android:duration="250"/> <item android:drawable="@drawable/movingduck8" android:duration="250"/>

最满意答案

你必须非常积极地缩放图像和帧率,以便在设备上回到Froyo时能够毫无例外地运行。 想想240x320的范围,大约10帧。 这是每个图像约300k字节。 不要认为你是明确的,因为png在磁盘上只有24K,每帧消耗的内存是未压缩的大小(W x H x 4bytes / pix)。

You'll have to scale images and framerates back pretty aggressively to get something that will function without exception on devices back to Froyo. Think more in the range of 240x320 with around 10 frames. that's about 300k bytes per image. Don't think you're in the clear cause the png is only 24K on disk, the memory consumed per frame is the uncompressed size (W x H x 4bytes/pix).

更多推荐

本文发布于:2023-07-17 13:16:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1144998.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:动画   如何在   animation   android   frame

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!