Android - TextureView Tutorial

<p >If you want to display a live video stream or any content stream such as video or an OpenGL scene, you can use TextureView provided by android in order to do that.</p> <p >In order to use TextureView, all you need to do is get its SurfaceTexture.The SurfaceTexture can then be used to render content. In order to do this, you just need to do instantiate an object of this class and implement SurfaceTextureListener interface. Its syntax is given below:</p> <pre class="prettyprint notranslate prettyprinted" > <span class="kwd" >private</span><span class="pln" > </span><span class="typ" >TextureView</span><span class="pln" > myTexture</span><span class="pun" >;</span><span class="pln" > </span><span class="kwd" >public</span><span class="pln" > </span><span class="kwd" >class</span><span class="pln" > </span><span class="typ" >MainActivity</span><span class="pln" > </span><span class="kwd" >extends</span><span class="pln" > </span><span class="typ" >Activity</span><span class="pln" > </span><span class="kwd" >implements</span><span class="pln" > </span><span class="typ" >SurfaceTextureListener</span><span class="pun" >{</span><span class="pln" > </span><span class="kwd" >protected</span><span class="pln" > </span><span class="kwd" >void</span><span class="pln" > onCreate</span><span class="pun" >(</span><span class="typ" >Bundle</span><span class="pln" > savedInstanceState</span><span class="pun" >)</span><span class="pln" > </span><span class="pun" >{</span><span class="pln" > myTexture </span><span class="pun" >=</span><span class="pln" > </span><span class="kwd" >new</span><span class="pln" > </span><span class="typ" >TextureView</span><span class="pun" >(</span><span class="kwd" >this</span><span class="pun" >);</span><span class="pln" > myTexture</span><span class="pun" >.</span><span class="pln" >setSurfaceTextureListener</span><span class="pun" >(</span><span class="kwd" >this</span><span class="pun" >);</span><span class="pln" > setContentView</span><span class="pun" >(</span><span class="pln" >myTexture</span><span class="pun" >);</span><span class="pln" > </span><span class="pun" >}</span><span class="pln" > </span><span class="pun" >}</span></pre> <p >After that, what you need to do is to override its methods. The methods are listed as follows &minus;</p> <pre class="prettyprint notranslate prettyprinted" > <span class="lit" >@Override</span><span class="pln" > </span><span class="kwd" >public</span><span class="pln" > </span><span class="kwd" >void</span><span class="pln" > onSurfaceTextureAvailable</span><span class="pun" >(</span><span class="typ" >SurfaceTexture</span><span class="pln" > arg0</span><span class="pun" >,</span><span class="pln" > </span><span class="kwd" >int</span><span class="pln" > arg1</span><span class="pun" >,</span><span class="pln" > </span><span class="kwd" >int</span><span class="pln" > arg2</span><span class="pun" >)</span><span class="pln" > </span><span class="pun" >{</span><span class="pln" > </span><span class="pun" >}</span><span class="pln" > </span><span class="lit" >@Override</span><span class="pln" > </span><span class="kwd" >public</span><span class="pln" > </span><span class="kwd" >boolean</span><span class="pln" > onSurfaceTextureDestroyed</span><span class="pun" >(</span><span class="typ" >SurfaceTexture</span><span class="pln" > arg0</span><span class="pun" >)</span><span class="pln" > </span><span class="pun" >{</span><span class="pln" > </span><span class="pun" >}</span><span class="pln" > </span><span class="lit" >@Override</span><span class="pln" > </span><span class="kwd" >public</span><span class="pln" > </span><span class="kwd" >void</span><span class="pln" > onSurfaceTextureSizeChanged</span><span class="pun" >(</span><span class="typ" >SurfaceTexture</span><span class="pln" > arg0</span><span class="pun" >,</span><span class="pln" > </span><span class="kwd" >int</span><span class="pln" > arg1</span><span class="pun" >,</span><span class="kwd" >int</span><span class="pln" > arg2</span><span class="pun" >)</span><span class="pln" > </span><span class="pun" >{</span><span class="pln" > </span><span class="pun" >}</span><span class="pln" > </span><span class="lit" >@Override</span><span class="pln" > </span><span class="kwd" >public</span><span class="pln" > </span><span class="kwd" >void</span><span class="pln" > onSurfaceTextureUpdated</span><span class="pun" >(</span><span class="typ" >SurfaceTexture</span><span class="pln" > arg0</span><span class="pun" >)</span><span class="pln" > </span><span class="pun" >{</span><span class="pln" > </span><span class="pun" >}</span></pre> <p >Any view that is displayed in the texture view can be rotated and its alpha property can be adjusted by using<b >setAlpha</b>and<b >setRotation</b>methods. Its syntax is given below &minus;</p> <pre class="prettyprint notranslate prettyprinted" > <span class="pln" >myTexture</span><span class="pun" >.</span><span class="pln" >setAlpha</span><span class="pun" >(</span><span class="lit" >1.0f</span><span class="pun" >);</span><span class="pln" > myTexture</span><span class="pun" >.</span><span class="pln" >setRotation</span><span class="pun" >(</span><span class="lit" >90.0f</span><span class="pun" >);</span></pre> <p >Apart from these methods, there are other methods available in TextureView class. They are listed below &minus;</p> <table class="table table-bordered" > <tbody > <tr > <th >Sr.No</th> <th >Method &amp; description</th> </tr> <tr > <td >1</td> <td ><b >getSurfaceTexture()</b> <p >This method returns the SurfaceTexture used by this view.</p> </td> </tr> <tr > <td >2</td> <td ><b >getBitmap(int width, int height)</b> <p >This method returns Returns a Bitmap representation of the content of the associated surface texture.</p> </td> </tr> <tr > <td >3</td> <td ><b >getTransform(Matrix transform)</b> <p >This method returns the transform associated with this texture view.</p> </td> </tr> <tr > <td >4</td> <td ><b >isOpaque()</b> <p >This method indicates whether this View is opaque.</p> </td> </tr> <tr > <td >5</td> <td ><b >lockCanvas()</b> <p >This method start editing the pixels in the surface</p> </td> </tr> <tr > <td >6</td> <td ><b >setOpaque(boolean opaque)</b> <p >This method indicates whether the content of this TextureView is opaque.</p> </td> </tr> <tr > <td >7</td> <td ><b >setTransform(Matrix transform)</b> <p >This method sets the transform to associate with this texture view.</p> </td> </tr> <tr > <td >8</td> <td ><b >unlockCanvasAndPost(Canvas canvas)</b> <p >This method finish editing pixels in the surface.</p> </td> </tr> </tbody> </table> <h2 >Example</h2> <p >The below example demonstrates the use of TextureView class. It crates a basic application that allows you to view camera inside a texture view and change its angle , orientation e.t.c.</p> <p >To experiment with this example , you need to run this on an actual device on which camera is present.</p> <table class="table table-bordered" > <tbody > <tr > <th >Steps</th> <th >Description</th> </tr> <tr > <td >1</td> <td >You will use android studio IDE to create an Android application and name it as TextureView under a package com.example.textureview. While creating this project, make sure you Target SDK and Compile With at the latest version of Android SDK to use higher levels of APIs.</td> </tr> <tr > <td >2</td> <td >Modify src/MainActivity.java file to add Activity code.</td> </tr> <tr > <td >3</td> <td >Modify layout XML file res/layout/activity_main.xml add any GUI component if required.</td> </tr> <tr > <td >5</td> <td >Run the application and choose a running android device and install the application on it and verify the results.</td> </tr> </tbody> </table> <p >Here is the content of<b >src/com.example.textureview/MainActivity.java</b>.</p> <pre class="prettyprint notranslate prettyprinted" > <span class="kwd" >package</span><span class="pln" > com</span><span class="pun" >.</span><span class="pln" >example</span><span class="pun" >.</span><span class="pln" >textureview</span><span class="pun" >;</span><span class="pln" > </span><span class="kwd" >import</span><span class="pln" > java</span><span class="pun" >.</span><span class="pln" >io</span><span class="pun" >.</span><span class="typ" >IOException</span><span class="pun" >;</span><span class="pln" > </span><span class="kwd" >import</span><span class="pln" > android</span><span class="pun" >.</span><span class="pln" >annotation</span><span class="pun" >.</span><span class="typ" >SuppressLint</span><span class="pun" >;</span><span class="pln" > </span><span class="kwd" >import</span><span class="pln" > android</span><span class="pun" >.</span><span class="pln" >app</span><span class="pun" >.</span><span class="typ" >Activity</span><span class="pun" >;</span><span class="pln" > </span><span class="kwd" >import</span><span class="pln" > android</span><span class="pun" >.</span><span class="pln" >graphics</span><span class="pun" >.</span><span class="typ" >SurfaceTexture</span><span class="pun" >;</span><span class="pln" > </span><span class="kwd" >import</span><span class="pln" > android</span><span class="pun" >.</span><span class="pln" >hardware</span><span class="pun" >.</span><span class="typ" >Camera</span><span class="pun" >;</span><span class="pln" > </span><span class="kwd" >import</span><span class="pln" > android</span><span class="pun" >.</span><span class="pln" >os</span><span class="pun" >.</span><span class="typ" >Bundle</span><span class="pun" >;</span><span class="pln" > </span><span class="kwd" >import</span><span class="pln" > android</span><span class="pun" >.</span><span class="pln" >view</span><span class="pun" >.</span><span class="typ" >Gravity</span><span class="pun" >;</span><span class="pln" > </span><span class="kwd" >import</span><span class="pln" > android</span><span class="pun" >.</span><span class="pln" >view</span><span class="pun" >.</span><span class="typ" >Menu</span><span class="pun" >;</span><span class="pln" > </span><span class="kwd" >import</span><span class="pln" > android</span><span class="pun" >.</span><span class="pln" >view</span><span class="pun" >.</span><span class="typ" >TextureView</span><span class="pun" >;</span><span class="pln" > </span><span class="kwd" >import</span><span class="pln" > android</span><span class="pun" >.</span><span class="pln" >view</span><span class="pun" >.</span><span class="typ" >TextureView</span><span class="pun" >.</span><span class="typ" >SurfaceTextureListener</span><span class="pun" >;</span><span class="pln" > </span><span class="kwd" >import</span><span class="pln" > android</span><span class="pun" >.</span><span class="pln" >view</span><span class="pun" >.</span><span class="typ" >View</span><span class="pun" >;</span><span class="pln" > </span><span class="kwd" >import</span><span class="pln" > android</span><span class="pun" >.</span><span class="pln" >widget</span><span class="pun" >.</span><span class="typ" >FrameLayout</span><span class="pun" >;</span><span class="pln" > </span><span class="kwd" >public</span><span class="pln" > </span><span class="kwd" >class</span><span class="pln" > </span><span class="typ" >MainActivity</span><span class="pln" > </span><span class="kwd" >extends</span><span class="pln" > </span><span class="typ" >Activity</span><span class="pln" > </span><span class="kwd" >implements</span><span class="pln" > </span><span class="typ" >SurfaceTextureListener</span><span class="pln" > </span><span class="pun" >{</span><span class="pln" > </span><span class="kwd" >private</span><span class="pln" > </span><span class="typ" >TextureView</span><span class="pln" > myTexture</span><span class="pun" >;</span><span class="pln" > </span><span class="kwd" >private</span><span class="pln" > </span><span class="typ" >Camera</span><span class="pln" > mCamera</span><span class="pun" >;</span><span class="pln" > </span><span class="lit" >@SuppressLint</span><span class="pun" >(</span><span class="str" >&quot;NewApi&quot;</span><span class="pun" >)</span><span class="pln" > </span><span class="lit" >@Override</span><span class="pln" > </span><span class="kwd" >protected</span><span class="pln" > </span><span class="kwd" >void</span><span class="pln" > onCreate</span><span class="pun" >(</span><span class="typ" >Bundle</span><span class="pln" > savedInstanceState</span><span class="pun" >)</span><span class="pln" > </span><span class="pun" >{</span><span class="pln" > </span><span class="kwd" >super</span><span class="pun" >.</span><span class="pln" >onCreate</span><span class="pun" >(</span><span class="pln" >savedInstanceState</span><span class="pun" >);</span><span class="pln" > setContentView</span><span class="pun" >(</span><span class="pln" >R</span><span class="pun" >.</span><span class="pln" >layout</span><span class="pun" >.</span><span class="pln" >activity_main</span><span class="pun" >);</span><span class="pln" > myTexture </span><span class="pun" >=</span><span class="pln" > </span><span class="kwd" >new</span><span class="pln" > </span><span class="typ" >TextureView</span><span class="pun" >(</span><span class="kwd" >this</span><span class="pun" >);</span><span class="pln" > myTexture</span><span class="pun" >.</span><span class="pln" >setSurfaceTextureListener</span><span class="pun" >(</span><span class="kwd" >this</span><span class="pun" >);</span><span class="pln" > setContentView</span><span class="pun" >(</span><span class="pln" >myTexture</span><span class="pun" >);</span><span class="pln" > </span><span class="pun" >}</span><span class="pln" > </span><span class="lit" >@Override</span><span class="pln" > </span><span class="kwd" >public</span><span class="pln" > </span><span class="kwd" >boolean</span><span class="pln" > onCreateOptionsMenu</span><span class="pun" >(</span><span class="typ" >Menu</span><span class="pln" > menu</span><span class="pun" >)</span><span class="pln" > </span><span class="pun" >{</span><span class="pln" > </span><span class="com" >// Inflate the menu; this adds items to the action bar if it is present.</span><span class="pln" > getMenuInflater</span><span class="pun" >().</span><span class="pln" >inflate</span><span class="pun" >(</span><span class="pln" >R</span><span class="pun" >.</span><span class="pln" >menu</span><span class="pun" >.</span><span class="pln" >main</span><span class="pun" >,</span><span class="pln" > menu</span><span class="pun" >);</span><span class="pln" > </span><span class="kwd" >return</span><span class="pln" > </span><span class="kwd" >true</span><span class="pun" >;</span><span class="pln" > </span><span class="pun" >}</span><span class="pln" > </span><span class="lit" >@SuppressLint</span><span class="pun" >(</span><span class="str" >&quot;NewApi&quot;</span><span class="pun" >)</span><span class="pln" > </span><span class="lit" >@Override</span><span class="pln" > </span><span class="kwd" >public</span><span class="pln" > </span><span class="kwd" >void</span><span class="pln" > onSurfaceTextureAvailable</span><span class="pun" >(</span><span class="typ" >SurfaceTexture</span><span class="pln" > arg0</span><span class="pun" >,</span><span class="pln" > </span><span class="kwd" >int</span><span class="pln" > arg1</span><span class="pun" >,</span><span class="pln" > </span><span class="kwd" >int</span><span class="pln" > arg2</span><span class="pun" >)</span><span class="pln" > </span><span class="pun" >{</span><span class="pln" > mCamera </span><span class="pun" >=</span><span class="pln" > </span><span class="typ" >Camera</span><span class="pun" >.</span><span class="pln" >open</span><span class="pun" >();</span><span class="pln" > </span><span class="typ" >Camera</span><span class="pun" >.</span><span class="typ" >Size</span><span class="pln" > previewSize </span><span class="pun" >=</span><span class="pln" > mCamera</span><span class="pun" >.</span><span class="pln" >getParameters</span><span class="pun" >().</span><span class="pln" >getPreviewSize</span><span class="pun" >();</span><span class="pln" > myTexture</span><span class="pun" >.</span><span class="pln" >setLayoutParams</span><span class="pun" >(</span><span class="kwd" >new</span><span class="pln" > </span><span class="typ" >FrameLayout</span><span class="pun" >.</span><span class="typ" >LayoutParams</span><span class="pun" >(</span><span class="pln" > previewSize</span><span class="pun" >.</span><span class="pln" >width</span><span class="pun" >,</span><span class="pln" > previewSize</span><span class="pun" >.</span><span class="pln" >height</span><span class="pun" >,</span><span class="pln" > </span><span class="typ" >Gravity</span><span class="pun" >.</span><span class="pln" >CENTER</span><span class="pun" >));</span><span class="pln" > </span><span class="kwd" >try</span><span class="pln" > </span><span class="pun" >{</span><span class="pln" > mCamera</span><span class="pun" >.</span><span class="pln" >setPreviewTexture</span><span class="pun" >(</span><span class="pln" >arg0</span><span class="pun" >);</span><span class="pln" > </span><span class="pun" >}</span><span class="pln" > </span><span class="kwd" >catch</span><span class="pln" > </span><span class="pun" >(</span><span class="typ" >IOException</span><span class="pln" > t</span><span class="pun" >)</span><span class="pln" > </span><span class="pun" >{</span><span class="pln" > </span><span class="pun" >}</span><span class="pln" > mCamera</span><span class="pun" >.</span><span class="pln" >startPreview</span><span class="pun" >();</span><span class="pln" > myTexture</span><span class="pun" >.</span><span class="pln" >setAlpha</span><span class="pun" >(</span><span class="lit" >1.0f</span><span class="pun" >);</span><span class="pln" > myTexture</span><span class="pun" >.</span><span class="pln" >setRotation</span><span class="pun" >(</span><span class="lit" >90.0f</span><span class="pun" >);</span><span class="pln" > </span><span class="pun" >}</span><span class="pln" > </span><span class="lit" >@Override</span><span class="pln" > </span><span class="kwd" >public</span><span class="pln" > </span><span class="kwd" >boolean</span><span class="pln" > onSurfaceTextureDestroyed</span><span class="pun" >(</span><span class="typ" >SurfaceTexture</span><span class="pln" > arg0</span><span class="pun" >)</span><span class="pln" > </span><span class="pun" >{</span><span class="pln" > mCamera</span><span class="pun" >.</span><span class="pln" >stopPreview</span><span class="pun" >();</span><span class="pln" > mCamera</span><span class="pun" >.</span><span class="pln" >release</span><span class="pun" >();</span><span class="pln" > </span><span class="kwd" >return</span><span class="pln" > </span><span class="kwd" >true</span><span class="pun" >;</span><span class="pln" > </span><span class="pun" >}</span><span class="pln" > </span><span class="lit" >@Override</span><span class="pln" > </span><span class="kwd" >public</span><span class="pln" > </span><span class="kwd" >void</span><span class="pln" > onSurfaceTextureSizeChanged</span><span class="pun" >(</span><span class="typ" >SurfaceTexture</span><span class="pln" > arg0</span><span class="pun" >,</span><span class="pln" > </span><span class="kwd" >int</span><span class="pln" > arg1</span><span class="pun" >,</span><span class="pln" > </span><span class="kwd" >int</span><span class="pln" > arg2</span><span class="pun" >)</span><span class="pln" > </span><span class="pun" >{</span><span class="pln" > </span><span class="com" >// TODO Auto-generated method stub</span><span class="pln" > </span><span class="pun" >}</span><span class="pln" > </span><span class="lit" >@Override</span><span class="pln" > </span><span class="kwd" >public</span><span class="pln" > </span><span class="kwd" >void</span><span class="pln" > onSurfaceTextureUpdated</span><span class="pun" >(</span><span class="typ" >SurfaceTexture</span><span class="pln" > arg0</span><span class="pun" >)</span><span class="pln" > </span><span class="pun" >{</span><span class="pln" > </span><span class="com" >// TODO Auto-generated method stub</span><span class="pln" > </span><span class="pun" >}</span><span class="pln" > </span><span class="pun" >}</span></pre> <p >Here is the content of<b >activity_main.xml</b></p> <pre class="prettyprint notranslate prettyprinted" > <span class="tag" >&lt;RelativeLayout</span><span class="pln" > </span><span class="atn" >xmlns:android</span><span class="pun" >=</span><span class="atv" >&quot;http://schemas.android.com/apk/res/android&quot;</span><span class="pln" > </span><span class="atn" >xmlns:tools</span><span class="pun" >=</span><span class="atv" >&quot;http://schemas.android.com/tools&quot;</span><span class="pln" > </span><span class="atn" >android:layout_width</span><span class="pun" >=</span><span class="atv" >&quot;match_parent&quot;</span><span class="pln" > </span><span class="atn" >android:layout_height</span><span class="pun" >=</span><span class="atv" >&quot;match_parent&quot;</span><span class="pln" > </span><span class="atn" >android:paddingBottom</span><span class="pun" >=</span><span class="atv" >&quot;@dimen/activity_vertical_margin&quot;</span><span class="pln" > </span><span class="atn" >android:paddingLeft</span><span class="pun" >=</span><span class="atv" >&quot;@dimen/activity_horizontal_margin&quot;</span><span class="pln" > </span><span class="atn" >android:paddingRight</span><span class="pun" >=</span><span class="atv" >&quot;@dimen/activity_horizontal_margin&quot;</span><span class="pln" > </span><span class="atn" >android:paddingTop</span><span class="pun" >=</span><span class="atv" >&quot;@dimen/activity_vertical_margin&quot;</span><span class="pln" > </span><span class="atn" >tools:context</span><span class="pun" >=</span><span class="atv" >&quot;.MainActivity&quot;</span><span class="pln" > </span><span class="tag" >&gt;</span><span class="pln" > </span><span class="tag" >&lt;TextureView</span><span class="pln" > </span><span class="atn" >android:id</span><span class="pun" >=</span><span class="atv" >&quot;@+id/textureView1&quot;</span><span class="pln" > </span><span class="atn" >android:layout_width</span><span class="pun" >=</span><span class="atv" >&quot;wrap_content&quot;</span><span class="pln" > </span><span class="atn" >android:layout_height</span><span class="pun" >=</span><span class="atv" >&quot;wrap_content&quot;</span><span class="pln" > </span><span class="atn" >android:layout_alignParentTop</span><span class="pun" >=</span><span class="atv" >&quot;true&quot;</span><span class="pln" > </span><span class="atn" >android:layout_centerHorizontal</span><span class="pun" >=</span><span class="atv" >&quot;true&quot;</span><span class="pln" > </span><span class="tag" >/&gt;</span><span class="pln" > </span><span class="tag" >&lt;/RelativeLayout&gt;</span></pre> <p >Here is the default content of<b >AndroidManifest.xml</b></p> <pre class="prettyprint notranslate prettyprinted" > <span class="pun" >&lt;?</span><span class="pln" >xml version</span><span class="pun" >=</span><span class="str" >&quot;1.0&quot;</span><span class="pln" > encoding</span><span class="pun" >=</span><span class="str" >&quot;utf-8&quot;</span><span class="pun" >?&gt;</span><span class="pln" > </span><span class="tag" >&lt;manifest</span><span class="pln" > </span><span class="atn" >xmlns:android</span><span class="pun" >=</span><span class="atv" >&quot;http://schemas.android.com/apk/res/android&quot;</span><span class="pln" > </span><span class="atn" >package</span><span class="pun" >=</span><span class="atv" >&quot;com.example.textureview&quot;</span><span class="pln" > </span><span class="atn" >android:versionCode</span><span class="pun" >=</span><span class="atv" >&quot;1&quot;</span><span class="pln" > </span><span class="atn" >android:versionName</span><span class="pun" >=</span><span class="atv" >&quot;1.0&quot;</span><span class="pln" > </span><span class="tag" >&gt;</span><span class="pln" > </span><span class="tag" >&lt;uses-permission</span><span class="pln" > </span><span class="atn" >android:name</span><span class="pun" >=</span><span class="atv" >&quot;android.permission.CAMERA&quot;</span><span class="tag" >/&gt;</span><span class="pln" > </span><span class="tag" >&lt;application</span><span class="pln" > </span><span class="atn" >android:allowBackup</span><span class="pun" >=</span><span class="atv" >&quot;true&quot;</span><span class="pln" > </span><span class="atn" >android:icon</span><span class="pun" >=</span><span class="atv" >&quot;@drawable/ic_launcher&quot;</span><span class="pln" > </span><span class="atn" >android:label</span><span class="pun" >=</span><span class="atv" >&quot;@string/app_name&quot;</span><span class="pln" > </span><span class="atn" >android:theme</span><span class="pun" >=</span><span class="atv" >&quot;@style/AppTheme&quot;</span><span class="pln" > </span><span class="tag" >&gt;</span><span class="pln" > </span><span class="tag" >&lt;activity</span><span class="pln" > </span><span class="atn" >android:name</span><span class="pun" >=</span><span class="atv" >&quot;com.example.textureview.MainActivity&quot;</span><span class="pln" > </span><span class="atn" >android:label</span><span class="pun" >=</span><span class="atv" >&quot;@string/app_name&quot;</span><span class="pln" > </span><span class="tag" >&gt;</span><span class="pln" > </span><span class="tag" >&lt;intent-filter&gt;</span><span class="pln" > </span><span class="tag" >&lt;action</span><span class="pln" > </span><span class="atn" >android:name</span><span class="pun" >=</span><span class="atv" >&quot;android.intent.action.MAIN&quot;</span><span class="pln" > </span><span class="tag" >/&gt;</span><span class="pln" > </span><span class="tag" >&lt;category</span><span class="pln" > </span><span class="atn" >android:name</span><span class="pun" >=</span><span class="atv" >&quot;android.intent.category.LAUNCHER&quot;</span><span class="pln" > </span><span class="tag" >/&gt;</span><span class="pln" > </span><span class="tag" >&lt;/intent-filter&gt;</span><span class="pln" > </span><span class="tag" >&lt;/activity&gt;</span><span class="pln" > </span><span class="tag" >&lt;/application&gt;</span><span class="pln" > </span><span class="tag" >&lt;/manifest&gt;</span></pre> <p >Let&#39;s try to run your TextureView application. I assume you have connected your actual Android Mobile device with your computer. To run the app from Android studio, open one of your project&#39;s activity files and click Run<img alt="Eclipse Run Icon" class="inline" src="http://www.tutorialspoint.com/android/images/eclipse_run.jpg" />icon from the toolbar. Before starting your application, Android studio will display following window to select an option where you want to run your Android application.</p> <p><img alt="Anroid TextureView Tutorial" src="http://www.tutorialspoint.com/android/images/choose_device.jpg" /></p> <p >Select your mobile device as an option and then check your mobile device which will display following screen. This screen has alpha property set to<b >0.5</b>and rotation set to<b >45.</b></p> <p><img alt="Anroid TextureView Tutorial" src="http://www.tutorialspoint.com/android/images/android_textureview1.jpg" /></p> <p >This screen has alpha property set to<b >1.5</b>and rotation set to<b >45</b>.</p> <p><img alt="Anroid TextureView Tutorial" src="http://www.tutorialspoint.com/android/images/android_textureview2.jpg" /></p> <p >This screen has alpha property set to<b >1.0</b>and rotation set to<b >90</b>.</p> <p><img alt="Anroid TextureView Tutorial" src="http://www.tutorialspoint.com/android/images/android_textureview3.jpg" /></p> <div></div>
RangeTime:0.005950s
RangeMem:235.55 KB
返回顶部 留言