Internship (28): SurfaceView + ListView + MediaPlayer Sliding When the gray coverage is equal

1. Gray coverage, or a layer of color on top

The problem should be that you add style to the listView, or to the current Window Added style, because surfaceView, if you don’t set it, should also have a default color value

When the listView slides, each item should be redrawn, at least the layout event will go. This leads to a layer of color on the surface. This is the first problem.

2. Video remains in the ListView

This problem is very Embarrassing, it is also when the listView is sliding, but the video is playing again, and if you switch between horizontal and vertical screens, this problem will become particularly serious.

The specific reason should be this: originally surfaceView It’s on the item, and the item is a view. When the video is played, MediaPlayer sets the display of the video to the surfaceHolder.

If you are playing the video, you switch between horizontal and vertical, resulting in The size of the surfaceView has changed, MediaPlayer re-renders the video image, and then comes back, there may be residual images,

Then if there is no horizontal and vertical screen switching , There will be residual shadows left. Why? I thought about the following reasons:

Because surfaceView has a characteristic. When you get an area from the window, this area is somewhat limited.

The most notable feature is: the area given to you by the window, you cannot slide, pan, zoom, etc., etc.

Because the surfaceView you applied for is only that big, You can’t change the size, position, transparency, etc. like ordinary views.

Then when you slide the listView, although the item changes, the surfaceView on the item does not follow. As a result, there will be afterimages, which is very embarrassing.

PS: The problem of afterimages is very troublesome. I have not thought of a solution yet, the last good solution , It must be drawn by yourself. This can definitely be solved.

Then the second option is: Use TextureView, which is the same as SurfaceView, but pay attention to the need to turn on hardware acceleration. The second is The play must be called by thread,

3. The problem of transparency: There are other activs in the background ity interface,

Theoretically, the current window (window) gives you a view area for you to use, and then the things you draw on the surfview will be on the top layer,

At this time, if your surfaceView is displayed on the current activity in the form of dialog, or PopWindow, etc., without re-rebuilding the activity,

Your surfaceView will be back There are many things, this is the first one, so it is recommended to use surfaceView in a new activity.

For this transparency problem, setting stlye Solved,

Leave a Comment

Your email address will not be published.