放大视频

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.example.myapplication.MainActivity">

    <FrameLayout
        android:id="@+id/full_video"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:visibility="gone"></FrameLayout>

    <WebView
        android:id="@+id/webView"
        android:layout_width="match_parent"
        android:layout_height="match_parent"></WebView>

    <ProgressBar
        android:id="@+id/progress"
        android:layout_width="50dp"
        android:layout_height="50dp"
        android:layout_gravity="center"
        android:visibility="gone"/>


</FrameLayout>

要加入FrameLayout 方便后面放大

     bd =(ImageView) findViewById ( R.id.imageView6 );
      bd.setOnClickListener ( new View.OnClickListener () {
          @Override
          public void onClick ( View v ) {
              Intent intent =new Intent ( v.getContext (),baidu.class);
       v.getContext ().startActivity ( intent );
          }
      } );

正常导入百度activity就可以了

public class baidu extends AppCompatActivity {
    WebView webview;
     WebSettings settings;

    private View customView ;

    protected FrameLayout  fullVideo;

    private ProgressBar progressBar;
    @Override
    protected void onCreate( Bundle savedInstanceState) {
        super.onCreate ( savedInstanceState );
        setContentView ( R.layout.baidu );
        webview = (WebView) findViewById ( R.id.webView );
        fullVideo =(FrameLayout) findViewById (R.id.full_video);
        progressBar=findViewById(R.id.progress);


        webview.loadUrl ( "file:///android_asset/demo.html" );

        webview.setWebChromeClient ( new  MyChrome() );

        webview.setWebViewClient(new WebViewClient());

        settings = webview.getSettings();
        settings.getJavaScriptEnabled ();

    }

所有东西都正常导入
加载setting
允许java script进行改变
载入 webviewclient
仿写 webchormClient(仿写里面的method 达到放大和缩小的效果)

 public class  MyChrome extends WebChromeClient {



        MyChrome () {
//            setRequestedOrientation ( ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE );
//
        }


        @Override
        public void onHideCustomView() {
            //退出全屏
            if (customView == null){
                return;
            }
            //移除全屏视图并隐藏
            ((FrameLayout)getWindow().getDecorView()).removeView(customView);
            customView = null;

            setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);


        }
        @Override
        public void onShowCustomView(View view, CustomViewCallback callback){
            customView = view;
            fullVideo.setVisibility(View.VISIBLE);
            fullVideo=((FrameLayout)getWindow().getDecorView());

            fullVideo.addView(customView, new FrameLayout.LayoutParams(-1, -1));//设置大屏
            setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);//设置横屏


        }

在manifest的相关activity 加入这句话
android:configChanges = “orientation|screenSize” 用以解决bug

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值