易采站长站为您分析Android编程实现WebView全屏播放的方法,结合实例形式较为详细的分析了Android实现WebView全屏播放的布局与功能相关技巧,需要的朋友可以参考下
本文实例讲述了Android编程实现WebView全屏播放的方法。,具体如下:
最近因为项目要用webview加载html5的视频,开始不能全屏播,做了很久才做出来!那按我的理解说下怎么实现全屏吧。
首先写布局文件activity_main.xml:
?
- <LinearLayout xmlns:android="http://www.easck.com/apk/res/android" xmlns:tools="http://www.easck.com/tools"
- android:id="@+id/container" android:layout_width="fill_parent"
- android:layout_height="fill_parent" android:orientation="vertical">
- <FrameLayout android:id="@+id/video_view"
- android:layout_width="fill_parent" android:layout_height="fill_parent"
- android:visibility="gone" ></FrameLayout>
- <Button android:id="@+id/video_landport"
- android:layout_width="fill_parent" android:layout_height="wrap_content"
- android:text="全屏不显示该按扭,点击切换横屏" android:gravity="center"
- /> <WebView
- android:id="@+id/video_webview" android:layout_width="fill_parent"
- android:layout_height="fill_parent" />
- </LinearLayout>
原理:实现全屏的时候把webview里的视频放到一个View(布局里的video_view控件)里面,然后把webview隐藏掉!这样就实现了全屏播放的!
现在具体来看看怎么实现的:
先放代码MainActivity.java:
- public class MainActivity extends Activity { private FrameLayout videoview;// 全屏时视频加载view










