【发布时间】:2016-07-18 14:37:33
【问题描述】:
Android/Xamarin 中动画列表的限制是什么?
我尝试了一个包含 10 帧的简单示例,每个帧小于 200kb,但仍然出现内存不足错误。我也尝试过this library,但出现位图解码错误。
TestActivity.xaml:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/myLayout"
android:clipChildren="false">
<ImageView
android:id="@+id/myAnimation"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerInParent="true"
android:adjustViewBounds="true"
android:src="@anim/TestAnimation"
android:scaleType="centerInside" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:paddingLeft="10dp"
android:paddingRight="20dp"
android:paddingTop="170dp"
android:paddingBottom="100dp"
android:clipChildren="false"
android:clipToPadding="false">
<ImageButton
android:id="@+id/triggerAnimation"
android:layout_height="20dp"
android:layout_width="60dp"
android:background="@android:color/transparent"
android:adjustViewBounds="false"
android:src="@drawable/myButton"
android:scaleType="fitXY"
android:padding="0dp"/>
</LinearLayout>
</RelativeLayout>
TestAnimation.xml:
<?xml version="1.0" encoding="utf-8"?>
<animation-list xmlns:android="http://schemas.android.com/apk/res/android"
android:oneshot="true">
<item android:drawable="@drawable/test0000" android:duration="33" />
<item android:drawable="@drawable/test0001" android:duration="33" />
<item android:drawable="@drawable/test0002" android:duration="33" />
<item android:drawable="@drawable/test0003" android:duration="33" />
<item android:drawable="@drawable/test0004" android:duration="33" />
<item android:drawable="@drawable/test0005" android:duration="33" />
<item android:drawable="@drawable/test0006" android:duration="33" />
<item android:drawable="@drawable/test0007" android:duration="33" />
<item android:drawable="@drawable/test0008" android:duration="33" />
<item android:drawable="@drawable/test0009" android:duration="33" />
<item android:drawable="@drawable/test0010" android:duration="33" />
TestActivity.cs(仅显示动画触发代码):
var imgView = FindViewById<ImageView>(Resource.Id.myAnimation);
AnimationDrawable animation = (AnimationDrawable)imgView.Drawable;
animation.Start();
【问题讨论】:
-
你的drawables的x/y尺寸是多少?
-
@SushiHangover 1280 x 1920