Issue
I tested setting an ImageView as a animation-list with some smaller png files and there was no problem, but trying this out for the background of the RelativeLayout works, but causes some serious lagging. This has been happening when I use the first 5 out of 16 png images and I noticed that it won't run if I add all of them due to memory out of bounds. Here's the relevant code (onFinish() is just when the countdown timer stops): Main Method:
@Override
public void onFinish() {
count.setText("Go!");
playing = true;
startTime = System.currentTimeMillis();
score.setVisibility(View.VISIBLE);
//Start background animation
RelativeLayout rl = (RelativeLayout) findViewById(R.id.main);
rl.setBackgroundResource(R.drawable.background);
AnimationDrawable frameAnimation = (AnimationDrawable) rl.getBackground();
frameAnimation.start();
}
The layout:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:background="@drawable/background"
tools:context=".MainActivity" >
Animation-list:
<?xml version="1.0" encoding="utf-8"?>
<animation-list
xmlns:android="http://schemas.android.com/apk/res/android"
android:oneshot="false" >
<item android:drawable="@drawable/background_0" android:duration="50"/>
<item android:drawable="@drawable/background_1" android:duration="50" />
<item android:drawable="@drawable/background_1" android:duration="50" />
<item android:drawable="@drawable/background_2" android:duration="50" />
<item android:drawable="@drawable/background_3" android:duration="50" />
<item android:drawable="@drawable/background_4" android:duration="50" />
<item android:drawable="@drawable/background_5" android:duration="50" />
</animation-list>
And here's some of the images in question in case there's something wrong with them http://imgur.com/a/vEmKn
Solution
Have you tried moving all of the relevant images/pngs into a
drawable-nodpi
folder inside of your res folder?
Answered By - Will Thomson
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.