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

How to animate a view being removed from a ViewPager?
Upload Picture to facebook
android: Put Text into a TextBox in Webview
Android osmdroid overlayItem tap detected with offset
The constructor DataBaseHelper is undefined
Starting new activity via using button
Some videos causing android media player to crash
Using Image in a Android Button with effects
DialogFragment doesn't pan with SOFT_INPUT_ADJUST_PAN
Action Bar padding differences between devices
MyFirstApp send button error
Android Game object scrolling
backbutton on my android webview crash
ViewPager with FragmentStatePager
Unable to instantiate componentinfo with SlidingMenu Library and SlidingFragmentActivity
Multiple Activities in Android

Categories

HOME
c99
redux-form
pda
object
hessian
mstest
grafana
static-site
rds
vxml
google-admin-sdk
google-schemas
ibeacon-android
spring-social
code-generation
plink
mongodb-csharp
bitnami
altera
gruntfile
modbus-tcp
feathersjs
smartclient
foreign-keys
shortest-path
simpleitk
poedit
jquery-ias
backpack-for-laravel
systemtime
exit
monit
onload
linked-data
scatter3d
powershell-ise
mustache
clickjacking
contacts
reactjs.net
indy10
numpy-broadcasting
xcode7.3
openalpr
print-css
lpsolve
http-request
httr
proget
java-bytecode-asm
arules
pybrain
universal-analytics
swingworker
smartfoxserver
redbeard-ios
microstation
hclust
omniauth-facebook
nss
turbo-prolog
createprocess
aspen
rasterize
dynamics-nav-2016
custom-errors
java-money
morton-number
cgi-bin
iced-coffeescript
wso2greg
sql-server-data-tools
teamcity-9.1
matlab-deployment
phpldapadmin
code-documentation
sonarqube-5.0
spy++
template-deduction
personalization
ora-00904
scrypt
ebay-lms
inappsettingskit
neos-server
node-blade
onload-event
wp7test
alice
android-sdk-2.3
extreme-programming
window-decoration
fitbounds
jquery-address
entity-attribute-value
workflow-services
pylucene
interprocess
burndowncharts
django-piston
build-environment
wcf-instancing
flvplayback
lemmatization

Resources

Database Users
RDBMS discuss
Database Dev&Adm
javascript
java
csharp
php
android
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App