5

I am using a view pager to show two fragments. One fragment contains a camera preview and the other one just a simple list view.

The problem is, that the whole swipe experience is not as smooth as it should be. And I guess the reason for that is because the UI Thread has to handle the view pager, the camera and the list view all at once.

Now, what can I do about that? What can I run in a background thread? Can I run the view pager in the background?

user2426316
  • 7,131
  • 20
  • 52
  • 83
  • "And I guess the reason for that is because the UI Thread has to handle the view pager, the camera and the list view all at once" -- rather than guessing, use Traceview and determine where your problem lies. BTW, I assume that you are using a `TextureView` for your camera preview. – CommonsWare Feb 14 '14 at 17:44
  • no, i am using surface view – user2426316 Feb 14 '14 at 17:45
  • I will be *very* surprised if `SurfaceView` works well in a `ViewPager`, particularly a "push buffers" one, such as one for camera preview. – CommonsWare Feb 14 '14 at 17:46
  • why? It works decent but as you said not too good – user2426316 Feb 14 '14 at 17:47
  • A `SurfaceView` is not a regular `View`. It is more of a hole that is punched in the window that is handed over to some low-level process, in this case the media framework for pushing preview images to the surface. A `SurfaceView` does not animate well as a result, and that may well be a contributor to your problems. – CommonsWare Feb 14 '14 at 17:51
  • See this answer. I tried this and its perfect : http://stackoverflow.com/questions/8155257/slowing-speed-of-viewpager-controller-in-android – Shahzeb Feb 14 '14 at 17:58
  • @CommonsWare i will try to use a texture view. But how can I then support devices with api lower then 14? – user2426316 Feb 14 '14 at 18:08
  • @user2426316: You would have to use a `SurfaceView` for those devices, and suffer whatever consequences you may encounter. – CommonsWare Feb 14 '14 at 18:41

0 Answers0