Android programming method for WebView full screen playback (with source code)

This paper describes the method of full screen playback of WebView by Android programming. Share with you for your reference, as follows:

Recently, because the project needs to load HTML5 video with WebView, it can't be broadcast in full screen at first. It took a long time to do it! Let's talk about how to achieve full screen according to my understanding.

First write the layout file activity_ main.xml:

Principle: when realizing full screen, put the video in WebView into a view (video_view control in the layout), and then hide the WebView! In this way, full screen playback is realized! Now let's see how to implement it:

Put the code mainactivity.java first:

I wrote a lot of comments in the code. I believe everyone can understand it. Of course, I am a rookie. I may have misunderstood some places! You can tell me what you know. Then I added a function to it, that is, click the button on WebView to switch the horizontal and vertical screen! In addition, when you click full screen play, force the horizontal screen to play full screen, and click return to return to the vertical screen! I don't use mobile phone gravity sensing to switch horizontal and vertical screens here! The code also adds a layout file of playback progress, which you can see in the source code!

Finally, let's talk about the androidmanifest. XML settings;

Access to the network add this sentence

Click here to download the complete example code.

I hope this article will help you in Android programming.

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
分享
二维码
< <上一篇
下一篇>>