android


Android Background Animation Lagging Game


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
Have you tried moving all of the relevant images/pngs into a
drawable-nodpi
folder inside of your res folder?

Related Links

Null pointer in retrofit callback when call getActivity
Update SQL Database without using ROW_ID
Android Show Fragment Over Activity Actionbar
Android NDK Cross Compile sys/signal.h: No such file or directory
'android:indeterminateDrawable' creating incorrect image size
Reg. the size of Android app in delphi
Hiding date and month from DatepickerDialog android
When is onAttachFragment called with a ViewPager
Cognito / S3 User Specific Policies
JSON data is read but cannot be converted to JSONArray
how to call an intent with my swipe buttons
use the new version of ADT
Auto notify when a new update done on server in phonegap
OnItemClickListener in gridview duplicate
Taxonomy of battery life in smartphone devices
how do I check if a circle shape is touched to apply actions to the shape e.g. change color of the shape or to update the score?

Categories

HOME
android
httparty
fabricjs
scikit-learn
turing-machines
design-patterns
gpu
rom
mapbox
jquery-ui
azure-container-service
jtextpane
fabric.io
openstreetmap
github-enterprise
pega
jxl
comsol
zerobrane
internationalization
google-content-api
xmonad
connector
asp.net-core-webapi
visual-glitch
guzzle
dpdk
backpack-for-laravel
easeljs
highstock
jquery-multiselect
winexe
tizen-tv
utorrent
keras-layer
openwhisk
python-import
modalviewcontroller
sql-delete
yowsup
searchkit
latitude-longitude
reactivekit
recurrent-neural-network
mcustomscrollbar
plaintext
httrack
openresty
gitlist
wcftestclient
oracleclient
jqchart
juice-ui
cudd
synonym
pre-build-event
sklearn-pandas
directdraw
eoferror
sha512
botan
canvg
omnifaces
fits
exceldatareader
android-vibration
pseudo-class
structuremap3
spy++
cocos3d
lambda-architecture
xml-dsig
qscrollarea
git-repo
getopt
inappsettingskit
cnf
font-awesome-4.0.0
wp7test
mysql-error-2013
swfobject
redis-py
fragmenttransaction
correlated-subquery
josql
apache-whirr
hibernateexception
webdev.webserver
uipagecontrol
load-time
silverlight-oob
cuda.net
linfu-dynamicproxy
httpcookie

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App