嗨我相当新的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) atis 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).
更多推荐
发布评论