原生UI定制
说明
- EasyClick 使用WebView支撑HTML的UI方式,并且扩展了JS方法,用于控制EC程序。
- 新建工程时候可以对应的模板,推荐使用Materialize模板,文档网址 http://www.materializecss.cn
- 也可以自己编写精美的HTML页面,更多JS方法的使用请参考模板中的用法
注意
- 使用html模板,layout文件夹会有css,htmljs,subjs,ui.js默认文件
- ui.js会是UI默认执行入口,会编译为字节码
- subjs文件夹存储的js文件会编译为字节码给ui.js调用,其他html无法调用
- htmljs存储的是html调用的js文件,html文件可以正常使用
- css文件存储的是css文件即可
- 如果错误的调用可能导致意外的问题,请遵守该规则使用
多tab标签支持
只要在工程的layout工程下新建一个ui.js文件即可 内容是
function main() {
ui.layout("参数配置", "main.html");
ui.layout("注册使用", "reg.html");
ui.layout("使用说明", "intr.html");
}
main();
脚本如何与JS交互
编写xml视图
- 使用webview加载本地的main.html ,tag=web
- 注意:需要layout.attr.xsd和layout.xsd两个文件,创建原生ui项目的layout文件下手动复制到当前项目的layout下
<?xml version="1.0" encoding="UTF-8" ?>
<LinearLayout
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:android="http://schemas.android.com/apk/res/android"
xsi:noNamespaceSchemaLocation="layout.xsd"
android:layout_height="match_parent"
android:layout_width="match_parent">
<WebView android:layout_width="wrap_content"
android:tag="web"
android:layout_height="wrap_content"
android:url="main.html"/>
</LinearLayout>
加载 xml
- 在ui.js中加载xml视图
function main() {
ui.layout("参数配置", "main.xml");
}
main();