Summary of differences between TextureView and surfaceview in Android

Both surfaceview and TextureView inherit from android.view.view

Different from other views, both can draw and render in independent threads, which greatly improves the rendering performance in dedicated GPU threads.

1、 Surfaceview specifically provides a drawing interface embedded in the view level. Developers can control the form of the interface, such as size, to ensure the correct position of the interface on the screen.

But there are limitations:

Because it is an independent layer of view, it is more like an independent window. Animation, translation and zoom cannot be added;

Two surfaceviews cannot overlap each other.

2、 TextureView is more like a general view, which can be zoomed, panned and animated like textview.

TextureView can only be used in windows with hardware acceleration turned on, and consumes more memory than surfaceview, with a delay of 1-3 frames.

3、 Both TextureView and surfaceview inherit from the view class, but TextureView can only be used in Apis after Android 4.0.

Surfaceview can update the UI in the child thread through the surfaceholder.addcallback method, and TextureView can update the UI in the child thread through textureview.setsurfacetexturelistener. Personally, I think the ability to update the UI in the child thread is the biggest advantage of the above two views over view.

However, there are some differences between the two methods of updating the picture. Due to the double buffer function of surfaceview, the picture can run more smoothly. However, due to the existence of its holder, there will be an interval between picture updates (not easy to express, direct to the figure above)

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>