天天看点

WebView的基础用法

新建一个WebView项目,然后修改activity_main.xml布局文件中的代码,如下所示:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"

xmlns:app="http://schemas.android.com/apk/res-auto"

xmlns:tools="http://schemas.android.com/tools"

android:layout_width="match_parent"

android:layout_height="match_parent"

tools:context="com.haobi.webviewdemo.MainActivity">

<WebView

android:id="@+id/web_view"

android:layout_width="match_parent"

android:layout_height="match_parent"/>

</LinearLayout>

1

2

3

4

5

6

7

8

9

10

11

12

13

然后,修改MainActivity中的代码,如下所示:

继续阅读