Surface View: Intro

Surface View: Intro - Lemberg Solutions Blog

Below you'll find some useful tips on Android  SurfaceView. The information is divided into three parts:

Surface View: Intro

Before emerging of Android 4.0 we were forced to use SurfaceView to deal with camera, GLSurfaceView to display OpenGL rendering and VideoView to play video. Two of them, GLSurfaceView and VideoView, are direct descendants of SurfaceView. Thats fine until you find out that SurfaceView creates a new window, placed behind your application’s window, in order to manage content.

Are you in trouble? Only if you want to move, scale, transform, animate or use SurfaceView inside scrollable container such as item ofListView or ViewPager - then SurfaceView shows it’s dark side. It will stretch, jump, fly away, squeeze, start blinking, and, as a result, you will probably get a heart attack faster then find out how to fix all these stuff.

So, what issues we are dealing with when working with SurfaceView:

  • unpredictable behavior inside scrollable container;
  • unpredictable behavior with animations;
  • no way to crop content.

Why Texture View is amazing?

Unlike SurfaceViewTextureView does not create a separate window but behaves as a regular view. This key difference allows a texture view to be moved, transformed, animated, etc.

TextureView is simple and powerful way to work with VideoCamera and OpenGL. Because it uses hardware accelerated 2D rendering - it is so fast and efficient.


  • TextureView is available only since API level 14

Original article here.