天天看點

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中的代碼,如下所示:

繼續閱讀