【WD】IAPP实用代码大全[第一期]

IAPP   © 文章版权由 admin 解释,禁止匿名转载

#楼主# 2021-11-20

建议开始楼主模式观看

那废话不多说

评论区见

[真棒]
【WD】原创

第六个
获取设备id
第六个有异常,请谅解
第七个
背景渐变动画
import "android.animation.ObjectAnimator"
import "android.animation.ArgbEvaluator"
import "android.animation.ValueAnimator"
import "android.graphics.Color"

local colorAnim = ObjectAnimator.ofInt(控件ID,"backgroundColor",{多个颜色值的 table})
colorAnim.setDuration(3000)--时长
colorAnim.setEvaluator(ArgbEvaluator())--估值器
colorAnim.setRepeatCount(ValueAnimator.INFINITE)--重复次数
colorAnim.setRepeatMode(ValueAnimator.REVERSE)--重复模式
colorAnim.start()
第八个
返回系统桌面
import "android.content.Intent"

local home=Intent(Intent.ACTION_MAIN)
home.addCategory(Intent.CATEGORY_HOME)
activity.startActivity(home)
第九个
模拟按键
local function sendKeyCode(keyCode)
return pcall(function()
Runtime.getRuntime().exec("input keyevent "..keyCode)
end)
end

--sendKeyCode(4)--返回键

--[[键值对照表
KeyEvevent 常量名 描述 常量值
KEYCODE_0 '0' key. 7
KEYCODE_1 '1' key. 8
KEYCODE_2 '2' key. 9
KEYCODE_3 '3' key. 10
KEYCODE_4 '4' key. 11
KEYCODE_5 '5' key. 12
KEYCODE_6 '6' key. 13
KEYCODE_7 '7' key. 14
KEYCODE_8 '8' key. 15
KEYCODE_9 '9' key. 16

KEYCODE_A 'A' key. 29
KEYCODE_B 'B' key. 30
KEYCODE_C 'C' key. 31
KEYCODE_D 'D' key. 32
KEYCODE_E 'E' key. 33
KEYCODE_F 'F' key. 34
KEYCODE_G 'G' key. 35
KEYCODE_H 'H' key. 36
KEYCODE_I 'I' key. 37
KEYCODE_J 'J' key. 38
KEYCODE_K 'K' key. 39
KEYCODE_L 'L' key. 40
KEYCODE_M 'M' key. 41
KEYCODE_N 'N' key. 42
KEYCODE_O 'O' key. 43
KEYCODE_P 'P' key. 44
KEYCODE_Q 'Q' key. 45
KEYCODE_R 'R' key. 46
KEYCODE_S 'S' key. 47
KEYCODE_T 'T' key. 48
KEYCODE_U 'U' key. 49
KEYCODE_V 'V' key. 50
KEYCODE_W 'W' key. 51
KEYCODE_X 'X' key. 52
KEYCODE_Y 'Y' key. 53
KEYCODE_Z 'Z' key. 54

META_ALT_LEFT_ON This mask is used to check whether the left ALT meta key is pressed. 16
META_ALT_MASK This mask is a combination of META_ALT_ON, META_ALT_LEFT_ON and META_ALT_RIGHT_ON. 50
META_ALT_ON This mask is used to check whether one of the ALT meta keys is pressed. 2
META_ALT_RIGHT_ON This mask is used to check whether the right the ALT meta key is pressed. 32
META_CAPS_LOCK_ON This mask is used to check whether the CAPS LOCK meta key is on. 1048576
META_CTRL_LEFT_ON This mask is used to check whether the left CTRL meta key is pressed. 8192
META_CTRL_MASK This mask is a combination of META_CTRL_ON, META_CTRL_LEFT_ON and META_CTRL_RIGHT_ON. 28672
META_CTRL_ON Th
第十个
获取屏幕尺寸
import "android.util.DisplayMetrics"
import "java.lang.Math"

local function getScreenPhysicalSize(ctx)
local dm = DisplayMetrics()
ctx.getWindowManager().getDefaultDisplay().getMetrics(dm)
return Math.sqrt(Math.pow(dm.widthPixels, 2) + Math.pow(dm.heightPixels, 2)) / (160 * dm.density);
end

print(getScreenPhysicalSize(activity))

评论

登录后才可发表内容
  • 主题

    863

  • 帖子

    39585

  • 关注者

    0

Copyright © 2019 凯特网.   Powered by HYBBS 2.3.4  

Runtime:0.2788s Mem:2035Kb