ChuckKelly
ChuckKelly

Reputation: 1740

Android Canvas inside of each row of listview without lag

I realize this is a highly custom implementation, but im porting a app over from IOS to Android that has these photos in a listview that the user needs to be able to fluidly whipe off in one fluid motion. The only thing I could find on github anywhere close to this was this: https://github.com/winsontan520/Android-WScratchView/tree/branch_image_overlay

but,this uses a surfaceview and when implemented in my listview its EXTREMLY laggy. I did a bit more research looking for something along the lines of a photoshop eraser and came across some stuff using canvas to accomplish something similar with a single drawing area , but im not quite sure if what I want to do is possible in Android and if spending the next day or two learning canvas would be a worthwhile investment or if im barking up the wrong tree. Is this the way to go to accomplish my goal?

Upvotes: 0

Views: 207

Answers (1)

Onur
Onur

Reputation: 5625

SurfaceView is actually a Canvas implementation that has some native improvements like duble buffering, vsync and such. But using it in a ListView is an overkill.

I say take your chance with a custom view. Just override the onDraw(Canvas canvas) and draw whatever you want. Learning canvas is pretty easy if you have some basic graphics knowledge.

As an another implementation idea, If you don't need all of your Views inside the ListView interacable when scrolling, you can use static images in ListView and when user touched one of them you replace static image with SurfaceView and go on. This way you only need one SurfaceView.

Also did you used the ViewHolder pattern ( http://developer.android.com/training/improving-layouts/smooth-scrolling.html ) when implementing the ListView? Might help with the performance but I'm not sure if it can be implementable in your case.

Upvotes: 1

Related Questions