autojs前端Ui界⾯表格布局代码分享,⼀个简单的登录界⾯例⼦,不含事件挂接说明
本⽂提供的代码仅供参考。不建议⽤于⽣产环境。
可能有些地⽅在最新版本的Auto.js上⾯需要做修改,才能运⾏。
Auto.js简介
Auto.js是利⽤安卓系统的“辅助功能”实现类似于按键精灵⼀样,可以通过代码模拟⼀系列界⾯动作的辅助⼯作。
与“按键精灵”不同的是,它的模拟动作并不是简单的使⽤在界⾯定坐标点来实现,⽽是类似与win⼀般,窗⼝句柄来实现的。
Auto.js使⽤JavaScript作为脚本语⾔,⽬前使⽤Rhino 1.7.7.2作为脚本引擎,⽀持ES5与部分ES6特性。
推荐教程
开发⽂档
⽂档尚在完善中,可能有⽂档描述和代码实际⾏为有出⼊的情况。
为什么要使⽤Auto.js Pro开发脚本,有什么特点?
吸引我使⽤Auto.js Pro的原因有很多。最主要的⼏个原因是:
Auto.js Pro能开发免ROOT的安卓脚本
Auto.js Pro基于节点操作,能开发全分辨率的脚本,⾃动适配各种安卓机型
Auto.js Pro丰富的UI组件,能⾃定义各种样式的安卓界⾯
Auto.js Pro使⽤的javascript的语法⽐较优雅,代码可读性强
Auto.js Pro的命令库⾮常的丰富,接⼝⽐较多
Auto.js Pro脚本⽂件体积⽐较⼩。1000⾏的代码,打包后的apk⽂件只有3-5M,还没有⼴告
⽰例代码
// 此代码由飞云脚本圈www.feiyunjs整理提供"ui";
ui.layout(
<frame>
<TableLayout
layout_width="match_parent"
layout_height="match_parent"
stretchColumns="1"
>
<TableRow>
<TextView
layout_width="wrap_content"
layout_height="wrap_content"
text="⽤户名:"/>
<EditText
javascript登录注册界面layout_width="match_parent"
layout_height="wrap_content"
hint="请输⼊⽤户名"/>
</TableRow>
<TableRow>
<TextView
layout_width="wrap_content"
layout_height="wrap_content"
text="密码:"/>
<EditText
layout_width="match_parent"
layout_height="wrap_content"
hint="请输⼊密码"
inputType="textPassword"/>
</TableRow>
<TableRow>
<Button
layout_height="wrap_content"
layout_width="wrap_content"
text="登录"
layout_span="2"/>
</TableRow>
</TableLayout>
</frame>
)