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 create texviews one below one programatically?
AppBarLayout weird behavior with slidinguppanel (GIF)
Android Studio: Fixing gradle-wrapper and re-importing project is taking too long
Where does Android interpret the media button?
Genymotion error “specified virtual device was not found in VirtualBox list”
Test with specific device?
How to get current open activity package name or class name in setting like device administration in android 5 and above?
Why non-ui thread can not modify view properties?
Android BitmapFactory.decodeFile returns null
Sending params and Json via HTTP POST
Bug trying to access sharedpreferences
Android offline speech recognition without a pop up dialog
Android pass selected item in listview to popupMenu
Checking if location services are enabled using react native
Exposing Android standard controls from virtual view hierarchy
Android: ANR when call getExternalFilesDir(null)

Categories

HOME
beautifulsoup
httparty
ng-idle
zend-framework
jwplayer
sublimetext
r-googlesheets
entity-framework-core
rds
mapbox
title
teechart
openpyxl
heap
gson
plist
mod-security
php-5.6
qsqlquery
azure-iot-hub
atlassian-stash
google-data-studio
boost-icl
database-connection
simpleitk
pimcore
tosca
dynamically-generated
draft-js-plugins
nstimer
inversion-of-control
datastax-enterprise-graph
sinch
userdefaults
panoramas
sql-server-2000
cart
jmockit
angularjs-material
dynamic-jasper
getlasterror
apic
reason
openproject
dm-script
cd
node-mssql
ods
linq-to-objects
google-data-api
comparison-operators
xv6
portforwarding
movilizer
claims
android-exoplayer
fclose
activeperl
aquamacs
android-testing
git-flow
ngmaterial
check-mk
oozie-coordinator
libjpeg
trigger.io
rxtx
polyline
cvxpy
vulcanize
macaulay2
android-dateutils
gogs
jclouds
clipboard.js
deep
hadoop-partitioning
phpgrid
opserver
text-search
typemock
rdflib
bufferedinputstream
android-broadcast
fits
primitive-types
iso-prolog
webfinger
gii
personalization
fpdi
xmltodict
windows-embedded-standard
mt4j
gd-graph
scrypt
printdialog
composite-component
saleslogix
jdb
floating-point-exceptions
apache-commons-dbutils
multiplatform
cac
undefined-index
vs-android
jqueryform
ajax-polling
zen
filesystemobject
httpcookie
commercial-application

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