IT. Expert System.

Android Reference

TextureView


android.view

Class TextureView

  • All Implemented Interfaces:
    Drawable.Callback, AccessibilityEventSource, KeyEvent.Callback
    Direct Known Subclasses:
    RSTextureView


    public class TextureView
    extends View

    A TextureView can be used to display a content stream. Such a content stream can for instance be a video or an OpenGL scene. The content stream can come from the application's process as well as a remote process.

    TextureView can only be used in a hardware accelerated window. When rendered in software, TextureView will draw nothing.

    Unlike SurfaceView, TextureView does not create a separate window but behaves as a regular View. This key difference allows a TextureView to be moved, transformed, animated, etc. For instance, you can make a TextureView semi-translucent by calling myView.setAlpha(0.5f).

    Using a TextureView is simple: all you need to do is get its SurfaceTexture. The SurfaceTexture can then be used to render content. The following example demonstrates how to render the camera preview into a TextureView:

      public class LiveCameraActivity extends Activity implements TextureView.SurfaceTextureListener {
          private Camera mCamera;
          private TextureView mTextureView;
    
          protected void onCreate(Bundle savedInstanceState) {
              super.onCreate(savedInstanceState);
    
              mTextureView = new TextureView(this);
              mTextureView.setSurfaceTextureListener(this);
    
              setContentView(mTextureView);
          }
    
          public void onSurfaceTextureAvailable(SurfaceTexture surface, int width, int height) {
              mCamera = Camera.open();
    
              try {
                  mCamera.setPreviewTexture(surface);
                  mCamera.startPreview();
              } catch (IOException ioe) {
                  // Something bad happened
              }
          }
    
          public void onSurfaceTextureSizeChanged(SurfaceTexture surface, int width, int height) {
              // Ignored, Camera does all the work for us
          }
    
          public boolean onSurfaceTextureDestroyed(SurfaceTexture surface) {
              mCamera.stopPreview();
              mCamera.release();
              return true;
          }
    
          public void onSurfaceTextureUpdated(SurfaceTexture surface) {
              // Invoked every time there's a new Camera preview frame
          }
      }
     

    A TextureView's SurfaceTexture can be obtained either by invoking getSurfaceTexture() or by using a TextureView.SurfaceTextureListener. It is important to know that a SurfaceTexture is available only after the TextureView is attached to a window (and onAttachedToWindow() has been invoked.) It is therefore highly recommended you use a listener to be notified when the SurfaceTexture becomes available.

    It is important to note that only one producer can use the TextureView. For instance, if you use a TextureView to display the camera preview, you cannot use lockCanvas() to draw onto the TextureView at the same time.

    See Also:
    SurfaceView, SurfaceTexture
    • Constructor Detail

      • TextureView

        public TextureView(Context context)
        Creates a new TextureView.
        Parameters:
        context - The context to associate this view with.
      • TextureView

        public TextureView(Context context,
                   AttributeSet attrs)
        Creates a new TextureView.
        Parameters:
        context - The context to associate this view with.
        attrs - The attributes of the XML tag that is inflating the view.
      • TextureView

        public TextureView(Context context,
                   AttributeSet attrs,
                   int defStyle)
        Creates a new TextureView.
        Parameters:
        context - The context to associate this view with.
        attrs - The attributes of the XML tag that is inflating the view.
        defStyle - The default style to apply to this view. If 0, no style will be applied (beyond what is included in the theme). This may either be an attribute resource, whose value will be retrieved from the current theme, or an explicit style resource.


Content

Android Reference

Java basics

Java Enterprise Edition (EE)

Java Standard Edition (SE)

SQL

HTML

PHP

CSS

Java Script

MYSQL

JQUERY

VBS

REGEX

C

C++

C#

Design patterns

RFC (standard status)

RFC (proposed standard status)

RFC (draft standard status)

RFC (informational status)

RFC (experimental status)

RFC (best current practice status)

RFC (historic status)

RFC (unknown status)

IT dictionary

License.
All information of this service is derived from the free sources and is provided solely in the form of quotations. This service provides information and interfaces solely for the familiarization (not ownership) and under the "as is" condition.
Copyright 2016 © ELTASK.COM. All rights reserved.
Site is optimized for mobile devices.
Downloads: 410 / 158871282. Delta: 0.06176 с