toastLog提示可以设置在屏幕上显示的位置吗?有时候OCR识别容易挡住部分按钮

已存档
如风
1
· 1 年前

回答

dgiij
251
· 1 年前

文档里toast调用确实没有办法修改显示位置,不过试了网上搜来的下面的代码,可以自己定义一个类似的调用实现你的需求:

//本脚本由autojs交流群553908361收集整理
function toastAt0(msg, x, y) {
  importClass(android.widget.Toast);
  importClass(android.view.Gravity);
  var toast = Toast.makeText(context, msg, Toast.LENGTH_SHORT);
  toast.setGravity(Gravity.TOP | Gravity.LEFT, x, y);
  toast.show();
}

function toastAt(msg, x, y) {
  ui.run(() => toastAt0(msg, x, y));
}

toastAt('测试语句',device.width/2,device.height/2)
//toastAt('测试语句',300,300)
sleep(2000)
已选为答案
2
0
如风
1
· 1 年前

感谢大佬

0
0