auto.js 中文文档 下载 App

UI 组件速查表——Auto.js 支持的全部原生控件

常用组件一览

Button — 按钮

<button id="btn_start" text="开始" w="*" h="auto"/>
<button id="btn_img" text="" bg="#ff0000"/>

Text — 文本标签

<text text="标题" textSize="18sp" textStyle="bold" gravity="center"/>

Input — 输入框

<input id="inp_name" hint="请输入用户名" inputType="text"/>
<input id="inp_pwd" hint="密码" inputType="password"/>
<input id="inp_num" inputType="number"/>

Checkbox / Radio — 复选 / 单选

<checkbox id="chk_agree" text="我同意"/>
<radiogroup>
  <radio text="选项 A"/>
  <radio text="选项 B"/>
</radiogroup>

Switch — 开关

<switch id="sw_auto" checked="true"/>

Image — 图片

<img src="file:///sdcard/test.png" w="100" h="100"/>

ProgressBar — 进度条

<progressbar id="pb_load" max="100" progress="0"/>

SeekBar — 滑动条

<seekbar id="sb_vol" max="15" progress="5"/>

List — 列表

<list id="list_apps">
  <item>
    <text id="item_name"/>
  </item>
</list>
ui.list_apps.setDataSource(["淘宝", "京东", "支付宝"]);
ui.list_apps.on("item_click", function(item, i) {
  toast("点击了:" + item);
});

Scroll — 可滚动容器

<scroll w="*" h="*">
  <vertical>
    <!-- 很多内容 -->
  </vertical>
</scroll>

Tab — 标签页

<tabs id="tabs">
  <tab title="任务">
    <vertical><text text="任务列表"/></vertical>
  </tab>
  <tab title="设置">
    <vertical><text text="设置项"/></vertical>
  </tab>
</tabs>

属性速查

属性类型说明
idstring组件 ID,代码中 ui.xxx 访问
textstring显示文字
textSizenumber/sp字号(单位 sp)
textColorcolor文字颜色 #rrggbb 或 #aarrggbb
textStylebold / italic文字样式
bgcolor / url背景色或图片
w* / auto / 数字宽度(* 撑满父容器,auto 自适应)
h* / auto / 数字高度
padding数字 / 四方向内边距
margin数字 / 四方向外边距
gravitycenter / top / bottom / left / right内部对齐
visibilityvisible / invisible / gone可见性
inputTypetext / password / number / phone输入类型
srcurl图片组件资源