easyClick自定义 toast 消息模板

xml文件

<?xml version="1.0" encoding="UTF-8" ?>

<LinearLayout
xmlns:xsi=“http://www.w3.org/2001/XMLSchema-instance”
xmlns:android=“http://schemas.android.com/apk/res/android”
xsi:noNamespaceSchemaLocation=“layout.xsd”
android:layout_height=“match_parent”
android:layout_width=“match_parent”

<LinearLayout
        android:layout_height="match_parent"
        android:layout_width="match_parent"
        android:orientation="horizontal"
        android:padding="5dp"
        android:cornerRadius="10dp"
        android:background="#66000000">
        <TextView android:layout_width="wrap_content"
                  android:layout_height="wrap_content"
                  android:layout_gravity="center"
                  android:textSize="18dp"
                  android:tag="msg"
                  android:textColor="#ffffff"
                  android:text="爱        好: "/>
    </LinearLayout>

function
function toast_yimi(msg,time,x,y) {
if(!msg){
logd(‘toast_yimi__空字符串’)
return;
}
let diff = msg.length * 12;
x = x || device.getScreenWidth()/2 - diff;
y = y || (device.getScreenHeight()/5)*4;
time = time || 3000;

thread.execAsync(function () {
    let tag = 'toast_ym'
    floaty.close(tag)
    floaty.touchable(tag,false);
    floaty.focusable(tag,false)
    let view = floaty.showFloatXml(tag,'toast_ym.xml',x,y);
    let textV = view.findViewWithTag('msg');
    ui.setViewValue(textV,msg);
    sleep(time);
    floaty.close(tag);
})

}

main.js 调用

toast_yimi(‘我的信息我的信息我的信息我的信息我的信息’,1000)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值