吐司自定义来个大佬,帮忙下。

qq_45860132 qq_45860132 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
论坛逛了一圈,还是没办法解决。 importClass("android.graphics.drawable.NinePatchDrawable") importClass("android.content.Context") importClass("android.graphics.Bitmap") importClass("android.graphics.BitmapFactory") importClass("android.graphics.NinePatch") importClass("android.os.Bundle") importClass("android.graphics.Rect") //图片需要.9.png格式 var imgPath = "./res/03.9.png"; imgPath = files.path(imgPath) function setBackground(view, path) { bitmap = BitmapFactory.decodeFile(path) chunk = bitmap.getNinePatchChunk(); npd = new NinePatchDrawable(context.getResources(), bitmap, chunk, new Rect(), null); view.setBackground(npd); } var 气泡 = function Toast9Patch(str) { importClass(android.widget.Toast); importClass(android.view.Gravity); importClass(android.graphics.Color); importPackage(android.content); // LENGTH_SHORT var toast = Toast.makeText(context,"",Toast.LENGTH_SHORT); view = ui.inflate( <frame > <TextView w="auto" id='_text' paddingTop="140px" paddingLeft="115px" paddingRight="80px" paddingBottom="35px" gravity="center|bottom" textColor="#FFFFFF" /> </frame>, null) view._text.setText(str) //背景 setBackground(view._text, imgPath); //视图 toast.setView(view); toast.show(); setTimeout(function () { toast.cancel(); }, 2000) } 气泡("1") sleep(1000) //不暂停运行第1。加暂停运行第2。 气泡("2") //想要的效果。吐司显示两秒。第1个现实一秒的时候会被第2个顶掉,第2个持续两秒。当sleep()大于两秒。先显示第1个,之后在显示第2个。
...全文

相关推荐

评论 12
收藏 已收藏
分享
返回顶部
qq_45860132
Android 80,490 成员 91,375 内容