Skip to content

Latest commit

 

History

History
37 lines (25 loc) · 1.87 KB

surface-view-intro.md

File metadata and controls

37 lines (25 loc) · 1.87 KB

Quickstart

Texture View

Intro

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

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

Problems

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

Why Texture View is amazing?

Unlike SurfaceView, TextureView 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 Video, Camera and OpenGL. Because it uses hardware accelerated 2D rendering - it is so fast and efficient.

Problems

  • TextureView is available only since API level 14