现在html5火热朝天,因为它能让手机与电脑适配。减少极大的代码量。在安卓中怎么使用html5呢?
有几种方法,这里使用WebView控件。顾名思义,该控件是显示web的。【支持html5标签】
这里简单的实现了js和java方法的互相调用。【带参数的调用】。
效果如下:
整个工程的结构如下:
注意红色框框,需要新建aessts【名字不能乱取】文件夹。将想要加载的本地html放入其中
新建activity_main.xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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"
android:background="#FFFFFF"
tools:context="com.example.aiden.example.MainAct