Solve the problem of SURFCEVIEW call setzorderontop (TRUE) to block other controls

  1. SurfaceView obscures the project background of other controls:

    Recently For the player project, because the underlying implementation uses Surface and OpenGL to switch rendering, both GLSurfaceView and SurfaceView are used in the layout. At the same time, the playback control buttons are customized, and the MediaCtroller control provided by Android itself is not used. In this context, the problem arises. If you have relevant development foundation, you should know that when SurfaceView and GLSurfaceView are in the same layout at the same time, if you want SurfaceView to display pictures or videos, you must call SurfaceView.setZOrderOnTop(true), which is It is said that SurfaceView must be placed on the top of the Activity display window to display normally, and then calling SurfaceView.setZOrderOnTop(true) causes other controls such as play, fast forward and other buttons to be obscured. There are many solutions on the Internet, such as the alternative solution to cover other components caused by the transparency of the SurfaceView, which is not perfect for the video playback page, because it draws related controls directly on the SurfaceView. Just imagine if you draw in certain areas of the SurfaceView Some buttons are bound to block part of the video screen, which is difficult for users to accept.

  2. Find a solution from the SurfaceView source code:

    Since none of the solutions found on the Internet can meet the requirements, there is no way to check it back. I read the source code of SurfaceView. When viewing the source code, I saw this method setZOrderMediaOverlay(boolean isMediaOverlay). Let’s take a look at the description of this method in the source code:

    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 is typically used to place overlays on top of an underlying media surface view.

< /p>

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}.

It roughly means whether the view layer on the surface of the control window is placed on top of the regular view layer.

In the end, I called setZOrderMediaOverlay(true) after calling setZOrderOnTop(true), OK, the occlusion problem was solved perfectly!

WordPress database error: [Table 'yf99682.wp_s6mz6tyggq_comments' doesn't exist]
SELECT SQL_CALC_FOUND_ROWS wp_s6mz6tyggq_comments.comment_ID FROM wp_s6mz6tyggq_comments WHERE ( comment_approved = '1' ) AND comment_post_ID = 1550 ORDER BY wp_s6mz6tyggq_comments.comment_date_gmt ASC, wp_s6mz6tyggq_comments.comment_ID ASC

Leave a Comment

Your email address will not be published.