[JavaScript] 纯文本查看 复制代码 /**横向悬浮窗口 */
var Xwin = floaty.rawWindow(
<vertical id="vertical" bg="#aaaaaa" w="200" h="150" gravity="center">
<canvas id="canvas" margin="2dp" layout_weight="1" />
<horizontal id="horizontal" margin="1dp" w="*" gravity="center">
<button id="btnDy" layout_weight="1" bg="#c0c0c0" text="暂停" />
<button id="butKuai" layout_weight="1" bg="#c5c5c5" text="切号" />
<button id="btnMove" layout_weight="1" bg="#c9c9c9" text="计心" />
<button id="btnEx" layout_weight="1" bg="#f0e8ff" text="开始" />
</horizontal>
</vertical>
);
/**移动窗体 */
Xwin.btnMove.setOnTouchListener(function (view, event) {
switch (event.getAction()) {
case event.ACTION_DOWN:
x = event.getRawX();
y = event.getRawY();
aw = Xwin.getWidth();
ah = Xwin.getHeight();
windowX = Xwin.getX();
windowY = Xwin.getY();
return true;
case event.ACTION_MOVE:
Xwin.setPosition(windowX + (event.getRawX() - x),
windowY + (event.getRawY() - y));
return true;
case event.ACTION_UP:
return true;
}
return true;
});
Xwin.btnEx.click(() => {
toastLog("退出脚本");
Xwin.close();
});
Xwin.setTouchable(false);
setInterval(() => {}, 1000);
|