怎么用UI做自定义个性化toast

是这样子的,小米的提醒十分的坑,用“APP名字:提醒内容”,关键显示还特别慢!

我想能不能做一个个性化的提醒,但是我对auto.js的UI、脚本间的通讯不熟悉。

还可以加入图片,显示一会就消失,或者点击屏幕任何位置就关闭显示。

toast本身是android 系统层的,小米修改了系统层的东西,想不一样,就不能调用系统层的toast。第一 让autoxjs不调用系统层的toast,也就是要调用 autoxjs 自定义的toast。但是autojs和autoxjs 都没有这个东西。第二,js代码本身就不调用autoxjs的默认toast,那js代码自己写一个。这个方案用Floaty 悬浮窗可以实现。第三,用1和2方案的结合,还是用js代码自己写一个,先用java代码写好一个自定义toast保证在,android上可以运行,是你想要的样子,然后在将java 代码转换为js 代码,就ok了java翻译为js

最后由 admin 编辑

感谢答复,我明白,就是弄悬浮窗口,然后再弹提示,不过不懂引用Java。

我还是用auto.js做一个全屏提示!
auto.js或者其他的脚本都可以调用!

就拿充电或者断开的情况演示,会弹出来不同的图片与语句!

全屏提示

var single = (function () {
var unique;

function getInstance() {
if (unique === undefined) {
unique = new Flash();
}
return unique;
}
return {
getInstance: getInstance
}
})();

function Flash() {}
Flash.prototype.update = function (content, x, y, color, t) {
this.content = content || '未传入参数'
this.x = x || random(100, 300)
this.y = y || random(100, 900)
this.color = color || -2278181
this.t = t || 2000
}
Flash.prototype.show = function () {
var window = floaty.rawWindow(
<card cardBackgroundColor="#aa00FF00" cardCornerRadius="18dp">
<text id="text" size="30dp" layout_width="wrap_content" layout_height="wrap_content"layout_gravity="center" gravity="center" paddingLeft="10" paddingRight="10" paddingTop="10" paddingBottom="10" >123</text>
</card>
);
window.text.setText(this.content);
window.text.setBackgroundColor(this.color);
window.setPosition(this.x, this.y);
setTimeout(() => {
window.close();
}, this.t);
}

function flash(content, x, y, color, t) {
var content = content.toString()
var f = single.getInstance()
f.update(content, x, y, color, t)
f.show()
}
for (let i = 0; i < 10; i++) {
var color = colors.rgb(random(0, 255), random(0, 255), random(0, 255))
flash(i * i * i * i * i + "", 300, 200 + i * 150, color, (i + 1) * 1000);
}
flash('hello world')
flash('Are you ok?')
flash('我很好')
flash('you are beautiful')
flash(" The way home")

复制的别人的,忘了在哪看过了,这里没有引用地址,抱歉了