Fix Surfaceview Call Setzorderontop (true) to mask other control issues

Source: Internet
Author: User

    1. Surfaceview obscures the project background of other controls:

      has been working on the player project recently, because the underlying implementation is switching rendering with surface and OpenGL, So both Glsurfaceview and Surfaceview are used in the layout, while the play control buttons are customized and do not use the Mediactroller controls provided by Android itself. In this context, the problem arises, if the students with the relevant development base should know, when Surfaceview and Glsurfaceview in a layout, If you want Surfaveview to display a picture or video, you must call Surfaceview.setzorderontop (true), that is, you must place the Surfaceview at the top level of the Activity Display window to display properly. Surfaceview.setzorderontop (True) is then called, causing other controls such as play, Fast forward, and so on to be obscured. There are a lot of solutions on the web, such as the solution of Surfaceview setting transparency to cover other components of the alternative, for the video playback of the page is not perfect, because it is directly on the Surfaceview to draw the relevant controls, Imagine if some of the surfaceview in some areas of the drawing of some buttons, is bound to block a portion of the video screen, which is difficult for users to accept.

    2. Find a solution from Surfaceview Source:

      Because the solution found on the Internet can not meet the requirements, there is no way to get back to view the next Surfaceview source code, When viewing the source code to see this method Setzordermediaoverlay (Boolean ismediaoverlay), let's look at the source code in the description of this method:

      Control whether the surface View ' s surface is placed on top of another regular surface view in the window (but still behind the window itself). This was typically used to place overlays on top of an underlying media surface view.

Note that this must be set before the Surface view's containing window is attached to the window manager.

Calling this overrides any previous call to {@link #setZOrderOnTop}.

This means that the view layer of the surface in the control window is placed at the top of the regular view layer.

Finally, I call Setzorderontop (true) after calling Setzordermediaoverlay (true), OK, occlusion problem perfectly solved!

This article is from the "Xicheng Day" blog, please make sure to keep this source http://marller.blog.51cto.com/8699646/1762028

Fix Surfaceview Call Setzorderontop (true) to mask other control issues

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.