EasyClick 原生UI連載
講師:Mr-老鬼,QQ:1156346325
其他文章電梯直達:
EasyClick 原生UI教程總綱
EasyClick 原生UI 懸浮窗動態顯示標識
先了解下兄弟篇 :EasyClick 原生 UI連載十二 之xml顯示懸浮窗
本篇視頻效果地址:xml懸浮窗動態顯示標識
接下來重點在下面:
float.xml代碼
<?xml version="1.0" encoding="utf-8"?><!--
~ Copyright(c) 2021,
~ 專案名稱:float
~ 檔案名稱:float.xml
~ 創建時間:2021/4/12 下午4:18
~ 作者:laogui
-->
<ScrollView 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="wrap_content"
android:layout_width="wrap_parent"
android:tag="float"
android:background="#000000">
<LinearLayout android:layout_width="wrap_parent"
android:layout_height="wrap_parent"
android:orientation="horizontal"
android:background="#00404040">
<TextView android:layout_height="wrap_parent"
android:layout_width="wrap_parent"
android:text="當前數值為:"
android:textColor="#FFFFFF" />
<TextView android:tag="tv"
android:layout_height="wrap_parent"
android:layout_width="wrap_parent"
android:text="0"
android:textColor="#009100" />
</LinearLayout>
</ScrollView>
main.js 代碼
function main() {
let p = floaty.requestFloatViewPermission(1000)
logd("是否有浮窗權限: " + p);
sleep(1000)
floaty.close("123")
sleep(1000);
let floatView = floaty.showFloatXml("123", "float.xml", 200, 700);
logd(floatView);
if (floatView) {
importPackage(android.widget);
importPackage(android.graphics);
let tvLog = floatView.findViewWithTag("tv");
logd(tvLog);
for (let i = 0, end = 100; i < end; i++) {
ui.run(1000, function () {
tvLog.setText(i.toString());
});
logd("當前運行次數"+i);
sleep(1000);
}
}
floaty.close("123");
toast("“懸浮窗 floatView 已關閉");
}
main();
效果

喜歡可以請我喝個咖啡謝謝,
------------------------------------------------著作權宣告------------------------------------------------------
本文著作權所有~Mr-老鬼 ~轉載請注明原文地址
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/276655.html
標籤:其他
上一篇:并查集之擴展域
