Smooth Endles Scrolling Background With Canvas?
Solution 1:
assuming you don't want for user to scroll this background by own you may use TranslateAnimation with INFINITE param for repeat mode, it will be smooth. create 2 ImageView
s horizontally (or even simple View
s and setting Bitmap
as background) and move their parent. when first get off the screen remove it and add another on other side. this is for background photo/image filling whole screen, if you have other size background just add more ImageView
s to create 2x or more summary length than width of the screen (which can be easly measured on in onCreate
or wherever. Just create something like Adapter
for background image or even you may tray existing projects/libs usually named smth like HorizontalScrollView
with Adapter
returning some large numer in getCount
, e.g. Integer.MAX_VALUE
about Bitmap
errors - note that Adapter
don't destroy lost/lefting View
s, but use them as next (recreates) - this is convertView
in getView(...)
method. use ViewHolder
pattern and you will use only two View
s with single Bitmap
setting (same refrence). you may create just once your static background Bitmap
in constructor and keep in LruCache preventing from recycle it. every device can handle bitmap with same size as screen
Post a Comment for "Smooth Endles Scrolling Background With Canvas?"