需要先在AndroidManifest中加入网络权限
<uses-permission android:name="android.permission.INTERNET" />
新建一个WebViewHtmlActivity类继承 AppCompatActivity
重写父类的onConfigurationChanged方法
@Override public void onConfigurationChanged(Configuration config) { super.onConfigurationChanged(config); switch (config.orientation) { case Configuration.ORIENTATION_LANDSCAPE: getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN); getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); break; case Configuration.ORIENTATION_PORTRAIT: getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); getWindow().addFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN); break; } }
最后通过
view.loadUrl(url);将连接显示出来 最终的效果如下
源码下载地址如下https://download.csdn.net/download/qq_34020487/10899124