-- 定义要检测的文件路径 local material3 = elgg.import("material3") -- 导入 m3 库 context = material3:getContext() -- 获取 m3 库的 context (不要用 local,不然 loadlayout 加载不了) context.setTheme(0x7f090069) -- 设置 material3 亮色主题 import "android.os.*" import "android.view.*" import "android.widget.*" import "android.graphics.PixelFormat" import "android.graphics.Color" import "android.graphics.drawable.GradientDrawable" import "android.graphics.drawable.StateListDrawable" import "com.google.android.material.materialswitch.MaterialSwitch" import "com.google.android.material.card.MaterialCardView" import "android.graphics.Color" import "android.content.res.ColorStateList" import "android.animation.LayoutTransition" import 'com.google.android.material.slider.Slider' import "android.animation.ObjectAnimator" -- 属性动画我吃柠檬 import "android.animation.AnimatorSet" -- 组合动画我吃柠檬🍋 import "android.view.animation.DecelerateInterpolator" -- 减速效果我吃柠檬🍋 import "android.animation.LayoutTransition" import "android.animation.ValueAnimator" import "android.view.animation.LinearInterpolator" import "android.renderscript.*" import "android.graphics.Bitmap" import "android.graphics.Canvas" import "android.os.Handler" import "android.os.Looper" --[[if gg.getWindowOrientation()==0 then gg.alert("请在横屏模式下打开") os.exit() else gg.alert("正在为您启动UI") end]] --[[ -- 函数: QingXu.button(名字, 按钮事件) -- 按钮, name 按钮名称, func 按钮点击事件 QingXu.text(文字, 颜色, 大小) QingXu.checkbox(view) 最多只能传两个(函数没写好) 写多了不显示! 例子: QingXu.checkbox({ {'按钮1', function() gg.alert('按钮1') end}, {'按钮2', function() gg.alert('按钮2') end} }) -- 生成悬浮窗 QingXu.menu(icon, title, menu) -- 菜单, icon 图标, title 标题, menu 菜单列表 ]] local window = activity.getSystemService("window") local QingXu = {} gg.setVisible(false) local HotPoint = luajava.bindClass("android.ext.HotPoint") local HP = HotPoint.getMethod("d") HotPoint = HotPoint.instance HotPoint.f() local function getVerticalBG(gtvb1, gtvb3, gtvb4, gtvb5) if not gtvb4 then gtvb4 = 0 gtvb5 = 0xff000000 end local colors = luajava.new(GradientDrawable) colors.setColor(gtvb1) colors.setCornerRadius(gtvb3) colors.setGradientType(GradientDrawable.LINEAR_GRADIENT) colors.setStroke(gtvb4, gtvb5) return colors end function zm_animation(view) view.setPivotX(0) view.setPivotY(0) local scaleXAnimator = ObjectAnimator.ofFloat(view, "scaleX", 0, 1) local scaleYAnimator = ObjectAnimator.ofFloat(view, "scaleY", 0, 1) --local alphaAnimator = ObjectAnimator.ofFloat(view, "alpha", 0, 0.6, 1) -- 添加淡入效果 local animatorSet = AnimatorSet() animatorSet.playTogether(scaleXAnimator, scaleYAnimator) animatorSet.setDuration(600) animatorSet.setInterpolator(DecelerateInterpolator()) -- 使用 post 确保在 UI 线程执行,但不会阻塞 view.post(function() animatorSet.start() end) end function miaobian(d, r, t, y) local drawable = GradientDrawable() drawable.setShape(GradientDrawable.RECTANGLE) drawable.setColor(t) -- 直接传入 0xAARRGGBB 格式的颜色值 drawable.setCornerRadii({r, r, r, r, r, r, r, r}) drawable.setStroke(d, y) -- 直接传入 0xAARRGGBB 格式的颜色值 return drawable end function getShepeBackground(color, radiu) local drawable = luajava.new(GradientDrawable) drawable.setShape(GradientDrawable.RECTANGLE) drawable.setColor(color) drawable.setCornerRadii({radiu, radiu, radiu, radiu, radiu, radiu, radiu, radiu}) return drawable end local function getButtonBG() local selector = StateListDrawable() local state = android.R.attr.state_pressed selector.addState({state}, getVerticalBG("0xffDEDFE4", 15)) selector.addState({-state}, getVerticalBG("0xffDEDFE4", 15)) return selector end local function getLayoutParams() local LayoutParams = WindowManager.LayoutParams local layoutParams = luajava.new(LayoutParams) layoutParams.type = Build.VERSION.SDK_INT >= 26 and LayoutParams.TYPE_APPLICATION_OVERLAY or LayoutParams.TYPE_PHONE layoutParams.format = PixelFormat.RGBA_8888 layoutParams.flags = LayoutParams.FLAG_NOT_FOCUSABLE | LayoutParams.FLAG_ALT_FOCUSABLE_IM layoutParams.gravity = Gravity.CENTER -- 位置居中 layoutParams.width = LayoutParams.WRAP_CONTENT layoutParams.height = LayoutParams.WRAP_CONTENT return layoutParams end -- 新开一个线程来执行功能 local function threadStart(runnable) local newRun = luajava.createProxy("java.lang.Runnable", runnable) local subThread = luajava.newInstance("java.lang.Thread", newRun) subThread:start() end local function log(text, color, size) -- 这是控制台输出的 local tmp = loadlayout { TextView, text = os.date("%m-%d %H:%M:%S ") .. text, textSize = size or '10sp', textColor = color, gravity = "left", layout_width = "wrap_content", } console_list.addView(tmp) console.fullScroll(View.FOCUS_DOWN) end -- 切换菜单 local change_menu -- 背景列表 只有单色 自行添加 十六进制颜色 local background_list = { getShepeBackground(0xffF4FAFB, 15), getShepeBackground(0x00F4FAFB, 15) } -- 开关 QingXu.switch = function(name, func1, func2) local sw sw = loadlayout({ MaterialSwitch; text = " "..name; textColor = "#000000"; padding = "5dp"; layout_width = "match"; layout_height = "match"; onClick = function() local func = sw.checked and func1 or func2 threadStart({ run = function() pcall(func) end }) end }) local tmp = loadlayout({ LinearLayout, background = getButtonBG(), layout_width = 'fill_parent', layout_height = "40dp", layout_margin = "2dp", gravity = "center_vertical", padding = { "0dp", "0dp", "6dp", "0dp" }, }) local rest = loadlayout({ LinearLayout, layout_width = 'fill_parent', layout_height = "wrap_content", gravity = "center_vertical", }) tmp.addView(sw) rest.addView(tmp) return rest end QingXu.button = function(name, func) local buttonLayout = { LinearLayout, layout_width = 'fill_parent', layout_height = "wrap_content", layout_margin = "5dp", background = getButtonBG(), onClick = function() if func then threadStart({ run = function() pcall(func) end }) end end, { LinearLayout, layout_width = 'fill_parent', layout_height = "wrap_content", orientation = "horizontal", gravity = "center_vertical", padding = "10dp", { TextView, text = name, textColor = "#000000", textSize = "14sp", layout_weight = 1, layout_marginLeft = "5dp", }, { ImageView, layout_width = "20dp", layout_height = "20dp", src = "/storage/emulated/0/神羽美化/heir.png", ColorFilter = "0xffeeeeee" } } } return loadlayout(buttonLayout) end QingXu.Image = function(name, size) local ImageLayout = { MaterialCardView, -- setCardBackgroundColor = 0xFFEDE5D8, -- 注意这里应该是数字而不是字符串 layout_width = "match_parent", layout_height = size or "100dp", radius = 15, strokeWidth = 0, elevation="2dp", clickable = true, focusable = true, checkable = true, { ImageView, layout_width = "match_parent", layout_height = "match_parent", src = name, scaleType = "centerCrop" -- 关键属性,使图片居中裁剪填充 } } return loadlayout(ImageLayout) end QingXu.seek = function(name,bian,smin,smax,nows) local sw _ENV[bian] =nows smin=tonumber(smin) smax=tonumber(smax) if _ENV[bian] == nil then _ENV[bian] = 1.0 end if not name then name = "未设置" end sw = loadlayout({ Slider, thumbHeight='23dp', trackHeight='15dp', tickVisible=false, TrackActiveTintList=ColorStateList({{}},{"0xff".."000000"}), TrackInactiveTintList=ColorStateList({{}},{"0x55".."000000"}), ThumbTintList=ColorStateList({{}},{"0xff".."000000"}), layout_width = 'match_parent', id=luajava.newId(name.."seekbar"), valueFrom=smin, valueTo=smax, value=nows, stepSize=1.0, }) sw.addOnChangeListener({ onValueChange = function(slider, value, fromUser) _ENV[bian] = value end }) local tmp = loadlayout({ LinearLayout, background = getButtonBG(), layout_width = 'fill_parent', layout_height = "40dp", layout_marginLeft = '2dp', layout_marginRight = '2dp', layout_marginTop = '2dp', layout_marginBottom = '2dp', gravity = "center_vertical", padding = { "0dp", "0dp", "6dp", "0dp" },{TextView, padding={"5dp","10dp","0dp","10dp",}, gravity = "top", textColor='#000000', textSize='13sp', text = name, id = luajava.newId(names), layout_width = 'wrap_content', layout_marginLeft = "5dp",} }) local rest = loadlayout({ LinearLayout, layout_width = 'fill_parent', layout_height = "wrap_content", gravity = "center_vertical", }) tmp.addView(sw) rest.addView(tmp) return rest end -- 文字 QingXu.text = function(txt, color, size) local tmp = { TextView, text = txt or "未设置文字", textSize = size or "18sp", textColor = color or "#545454", layout_width = "wrap_content", } return loadlayout(tmp) end layoutTransition=LayoutTransition() function visi (tid , ttid) local tview = luajava.getIdView (tid) local ttview = luajava.getIdView (ttid) if not tview then return 0 end if tonumber (tostring (tview : getVisibility ())) == 8.0 then tview.setVisibility (View.VISIBLE) else tview.setVisibility (View.GONE) end end -- 初始化 colorvs 变量 local colorvs = {} boxes={} boxpic={} function visi(tid, ttid) local tview = luajava.getIdView(tid) local arrowView = luajava.getIdView(tid.."_arrow") -- 获取箭头图标视图 if not tview then return 0 end if tonumber(tostring(tview:getVisibility())) == 8.0 then tview.setVisibility(View.VISIBLE) -- 展开时旋转箭头向下90度 local anim = ObjectAnimator.ofFloat(arrowView, "rotation", 0, 90) anim.setDuration(300) anim.start() else tview.setVisibility(View.GONE) -- 收缩时旋转箭头回到0度 local anim = ObjectAnimator.ofFloat(arrowView, "rotation", 90, 0) anim.setDuration(300) anim.start() end end function QingXu.box(views) local tid = "box"..string.randomUUID(true) colorvs[#colorvs+1] = {"box",tid} local arrowIcon = { ImageView, id = luajava.newId(tid.."_arrow"), layout_width="wrap_content", layout_height="wrap_content", src = "/storage/emulated/0/神羽美化/heir.png", ColorFilter = "0xffeeeeee" } local ttid = tid.."6" local firadio = { LinearLayout, layout_width='fill_parent', background = getShepeBackground(0xffDEDFE4, 15), layout_height="wrap_content", layout_margin="4dp", orientation="vertical", LayoutTransition = LayoutTransition() } if type(views[1]) == "string" or type(views[1]) == "number" then firadio[#firadio + 1] = { LinearLayout, layout_width='fill_parent', layout_height="40dp", gravity="center_vertical", onClick = function() visi(tid,ttid) end, { LinearLayout, layout_width='fill_parent', layout_height="36dp", layout_marginRight="4dp", layout_marginLeft="4dp", gravity="center_vertical", background = getShepeBackground(0xffDEDFE4, 15), { TextView, gravity="center_vertical", text=views[1].."[展开]", textColor="0xff010101", textSize="15sp", layout_weight=1, layout_marginLeft="10dp", layout_marginRight="20dp", layout_width='fill_parent', }, { LinearLayout, padding={"0dp","0dp","15dp","0dp"}, layout_width="30dp", layout_height="30dp", gravity="center", arrowIcon } } } else gg.alert("QingXu.box 的 table 内第一个元素必须是 string") os.exit() end local contentLayout = { LinearLayout, layout_marginLeft="10dp", layout_marginRight="10dp", layout_marginBottom="10dp", orientation="vertical", visibility="gone", id=luajava.newId(tid), layout_width='fill_parent', } for i=2,#views do table.insert(contentLayout, views[i]) end local finalLayout = loadlayout(firadio) local contentView = loadlayout(contentLayout) finalLayout.addView(contentView) boxes[tid] = contentView return finalLayout end QingXu.checkbox = function(views) if #views == 0 then return end -- 创建主垂直布局 local mainLayout = loadlayout({ LinearLayout, layout_width = 'fill_parent', layout_height = 'wrap_content', orientation = 'vertical' }) -- 创建横向滑动布局 local scrollView = loadlayout({ LinearLayout, layout_width = 'wrap_content', layout_height = 'wrap_content', orientation = 'vertical', id = 'rows_container' }) mainLayout.addView(scrollView) -- 计算每行最多3个复选框 local buttonsPerRow = 5 local currentRow = nil local buttonsInCurrentRow = 0 for i, v in ipairs(views) do -- 每行开始时创建新的水平布局 if buttonsInCurrentRow % buttonsPerRow == 0 then currentRow = loadlayout({ LinearLayout, layout_width = "match_parent"; layout_height = 'wrap_content', orientation = 'horizontal', id = 'row_'..math.ceil(i/buttonsPerRow) }) rows_container.addView(currentRow) end local sw = loadlayout({ CheckBox; layout_width = "match_parent"; layout_height = '32dp', layout_weight = "1", buttonTintList=ColorStateList({{android.R.attr.state_checked},{-android.R.attr.state_checked}},{0xff010101,0xff010101},{0xff010101,0xff010101}), text = v[1], textSize = "10sp", textColor = "0xff010101"; onClick = function(view) local isChecked = view.isChecked() if isChecked and v[2] then pcall(v[2]) -- 选中状态回调 elseif not isChecked and v[3] then pcall(v[3]) -- 取消选中状态回调 end end }) local buju = loadlayout({ LinearLayout, layout_width = "match_parent"; layout_height = "wrap_content", layout_margin = "3dp", layout_weight = "1", sw }) -- 添加到当前行 currentRow.addView(buju) buttonsInCurrentRow = buttonsInCurrentRow + 1 end return mainLayout end QingXu.menu = function(icon, title, menu) PageNum={} local menu_list={ LinearLayout, layout_height = "wrap", gravity = "center", layout_width = "match_parent", orientation = "vertical", id = "menu_list", } local menu_lit={ LinearLayout, layout_height = "wrap", gravity = "center", layout_width = "match_parent", orientation = "vertical", id = "menu_lit", } local menu_layout = {} local icon_list = {} SecondPage={} NowPage=1 MainMenus={ LinearLayout, layout_height = "match_parent", id = "main", layout_width = "match_parent", orientation = "vertical", } SecondBG={} FirstBG={} TitleName={} for i, v in ipairs(menu) do TitleName[i]={} FirstBG[i]="0xff8F495A" SecondBG[i]={} PageNum[i] = #v['二级分页'] local SecondPageV = { LinearLayout, -- visibility = i == 1 and 'visible' or 'gone', layout_height = "wrap", gravity = "center", layout_width = "match_parent", id = luajava.newId('SecondPageV' .. i), } for j=1,#v['二级分页'] do TitleName[i][j]=v['二级分页'][j]['分页名字'] SecondBG[i][j]=miaobian(0, 15, "0xffF3DCDF", "0xff006970") local item = { LinearLayout, layout_width = "wrap", layout_margin = "2dp", layout_height = "match_parent", id=luajava.newId('Second'..i..'P'..j), background = SecondBG[i][j], gravity = "center", onClick = function() change_area(j) end, { ImageView, layout_width = "30dp", layout_height = "30dp", layout_margin = "3dp", src = v['二级分页'][j]['分页logo'] or icon }, { LinearLayout, layout_width = "wrap", layout_height = "match_parent", layout_margin = "5dp", orientation = "vertical", { TextView, text = v['二级分页'][j]['分页名字'], textColor = "0xff010101", textSize = "12sp", layout_width = "wrap", layout_height = "wrap", }, { TextView, text = v['二级分页'][j]['分页描述'] or "测试文本xxxxxxx", textColor = "0xff515151", textSize = "8sp", layout_width = "wrap", layout_height = "wrap", }, } } table.insert(SecondPageV,item) local funclayout = { LinearLayout, layout_width = "match_parent", layout_marginLeft = "5dp", id = 'layout_func' .. i .. 'p' .. j, layout_marginRight = "5dp", gravity = "center_horizontal", orientation = "vertical", } for _, k in ipairs(v['二级分页'][j]['分页菜单']) do table.insert(funclayout, k) end table.insert(MainMenus, { LinearLayout, id=luajava.newId('Menu'..i..'P'..j), layout_height = "match_parent", layout_width = "match_parent", orientation = "vertical", layout_marginBottom = "45dp", -- visibility = 'gone', { ScrollView, fillViewport = "true", layout_width = "match_parent", layout_height = "match_parent", funclayout }, }) end table.insert(menu_list, SecondPageV) local items = loadlayout { LinearLayout, layout_width = "match_parent", layout_margin = "2dp", layout_height = "wrap", gravity = "center", orientation = "vertical", onClick = function() change_menu(i) end, { ImageView, layout_width = "30dp", layout_height = "30dp", layout_margin = "3dp", src = v['分区logo'] or icon }, { TextView, text = v['分区名字'], id=luajava.newId('FirstBG'..i), textSize = "12sp", layout_width = "wrap", layout_height = "wrap", textColor = FirstBG[i], }, } table.insert(menu_lit,items) -- 给右侧菜单加功能 end local layout = { CardView, layout_height = "wrap_content", layout_width = "wrap_content", id = "windows", --layout_margin = "10dp"; background = getShepeBackground(0xffFBF2F7, 15), --elevation = "10dp"; { RelativeLayout, layout_height = UI高度, layout_width = UI宽度, id = "ooo", background = getShepeBackground(0xffFBF2F7, 15), { RelativeLayout, layout_width = "match_parent", layout_height = "match_parent", id = "snowContainer", elevation="6dp",--调整这个可以调整雪花在顶层或者底层 如果被东西遮挡可以加1dp background = "#00000000", -- 透明背景 }, { -- 功能部分 LinearLayout, layout_height = "match_parent", orientation = "vertical", gravity = "center", { LinearLayout, layout_height = "match_parent", layout_width = "match_parent", layout_width = "80dp", { LinearLayout, layout_height = "match_parent", layout_width = "match_parent", orientation = "vertical", background = getShepeBackground(0xffF9EDF1, 0), gravity = "center", layout_weight = "1", { CircleImageView, layout_width = "40dp", clickable = true, focusable = true, layout_marginTop = "5dp", id = "yddd", src = icon, layout_height = "40dp", }, { TextView, layout_width = "match", layout_height = "30dp", gravity = "center", text = namesy, textColor = "0xff8F495A", }, { -- 侧边栏 菜单按钮 ScrollView, layout_height = "match_parent", layout_width = "match_parent", menu_lit }, }, }, }, -- 下面是按钮,用代码添加 { LinearLayout, layout_marginLeft = "90dp", layout_height = "match_parent", layout_width = "match_parent", orientation = "vertical", { LinearLayout, layout_height = "30dp", layout_width = "match", { RelativeLayout, layout_width = "match", layout_height = "30dp", { TextView, id = "current_page_title", -- 添加ID layout_width = "80dp", layout_height = "30dp", layout_margin = "5dp", text = "", -- 默认文本 textColor = "#8F495A", textSize = "18sp", layout_marginLeft = "20dp", }, { ImageView, layout_width = "30dp", layout_height = "30dp", layout_margin = "5dp", src = "/storage/emulated/0/神羽美化/图标.png", id = 'window_exit', layout_alignParentRight = "true", layout_marginRight = "40dp", }, { ImageView, layout_width = "30dp", layout_height = "30dp", layout_margin = "5dp", src = "/storage/emulated/0/神羽美化/图标.png", id = 'lessen', layout_alignParentRight = "true", }, }, }, MainMenus }, { -- 侧边栏 菜单按钮 HorizontalScrollView, background = getShepeBackground(0xffFFF9FF, 15), layout_height = "40dp", layout_width = "match_parent", elevation="3dp", layout_alignParentBottom = "true", layout_marginBottom = "5dp", layout_marginRight = "5dp", layout_marginLeft = "85dp", menu_list }, }, }; local ball = { LinearLayout, layout_height = "fill", layout_width = "fill", { LinearLayout, layout_width = "50dp", { ImageView, layout_width = "40dp", id = "suspended_ball", --icon = icon, src = icon, --background = icon, layout_height = "40dp", } } } ball = loadlayout(ball) local window_layout = loadlayout(layout) windows.setBackground(background_list[1]) -- 设置背景 NowPage=1 local mainLayoutParams = getLayoutParams() change_menu = function(j) NowPage=j for i=1,#PageNum do luajava.getIdView('SecondPageV'..i).setVisibility(View.GONE) luajava.getIdView('FirstBG'..i).setTextColor(0xff010101) end luajava.getIdView('FirstBG'..NowPage).setTextColor(FirstBG[NowPage]) luajava.getIdView('SecondPageV'..j).setVisibility(View.VISIBLE) if not SecondPage[j] then change_area(1) else change_area(SecondPage[j]) end end function change_area(x) SecondPage[NowPage]=x for i=1,#PageNum do for j=1,PageNum[i] do luajava.getIdView('Menu'..i..'P'..j).setVisibility(View.GONE) luajava.getIdView('Second'..i..'P'..j).setBackground(nil) luajava.getIdView('Menu'..i..'P'..j).setVisibility(View.GONE) end end zm_animation(luajava.getIdView('Menu'..NowPage..'P'..x)) luajava.getIdView('Second'..NowPage..'P'..x).setBackground(SecondBG[NowPage][x]) luajava.getIdView('Menu'..NowPage..'P'..x).setVisibility(View.VISIBLE) current_page_title.setText(TitleName[NowPage][x]) end -- 退出按钮 window_exit.onClick = function() HP.invoke(HotPoint, nil) window.removeView(window_layout, mainLayoutParams) --clearSnowAnimation() Looper.myLooper().quitSafely() end do -- 这是创建两个悬浮窗缩小放大的按钮, 还有移动事件 local t = { { suspended_ball, ball, window_layout }, { lessen, window_layout, ball } } local tt = { { yddd, window_layout }, { suspended_ball, ball } } for i, v in ipairs(t) do v[1].onClick = function() -- 悬浮球点击 if v[1] == suspended_ball then window.removeView(v[2], mainLayoutParams) window.addView(v[3], mainLayoutParams) elseif v[1] == lessen then Handler().postDelayed(function() window.removeView(v[2], mainLayoutParams) window.addView(v[3], mainLayoutParams) end, 0) -- 600ms是动画持续时间 end end local x, y, RawX, RawY = 0, 0, 0, 0 tt[i][1].onTouch = function(_, event) local Action = event.getAction() if Action == MotionEvent.ACTION_DOWN then RawX, RawY = event.getRawX(), event.getRawY() x, y = mainLayoutParams.x, mainLayoutParams.y elseif Action == MotionEvent.ACTION_MOVE then mainLayoutParams.x = tonumber(x) + (event.getRawX() - RawX) mainLayoutParams.y = tonumber(y) + (event.getRawY() - RawY) window.updateViewLayout(tt[i][2], mainLayoutParams) end end end end -- 雪花动画配置 local snowConfig = { flakeCount = 25, -- 雪花数量 minSize = 10, -- 最小尺寸(dp) maxSize = 30, -- 最大尺寸(dp) minSpeed = 2000, -- 最慢下落速度(毫秒) maxSpeed = 4000, -- 最快下落速度(毫秒) minDelay = 400, -- 最小出现延迟(毫秒) maxDelay = 800, -- 最大延迟时间 windEnabled = true, -- 是否启用风力效果 maxWind = 10, -- 最大风力偏移 minRotation = -360, -- 最小旋转角度 maxRotation = 360, -- 最大旋转角度 rotationProbability = 0.6, -- 旋转概率(0-1之间) flakeImages = { -- 雪花表情符号 "❄️", "❄", "❅", "❆", "❉", "❊" } } -- 创建单个雪花 local function createSnowFlake(delay) if not isSnowActive or snowFlakeCount >= snowConfig.flakeCount then return end snowFlakeCount = snowFlakeCount + 1 Handler().postDelayed(function() if not isSnowActive then return end -- 随机选择雪花样式 local flakeChar = snowConfig.flakeImages[math.random(1, #snowConfig.flakeImages)] local flakeSize = math.random(snowConfig.minSize, snowConfig.maxSize) local flakeView = TextView(activity) flakeView.setText(flakeChar) flakeView.setTextSize(flakeSize) flakeView.setLayoutParams(LinearLayout.LayoutParams( ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT )) snowContainer.addView(flakeView) local containerWidth = snowContainer.getWidth() local startX = math.random(0, containerWidth) local startY = math.random(-100, -20) flakeView.setX(startX) flakeView.setY(startY) flakeView.post(function() if not isSnowActive then snowContainer.removeView(flakeView) return end local containerHeight = snowContainer.getHeight() local duration = math.random(snowConfig.minSpeed, snowConfig.maxSpeed) local windOffset = snowConfig.windEnabled and math.random(-snowConfig.maxWind * 2, snowConfig.maxWind * 2) or 0 -- 创建基础动画 local animY = ObjectAnimator.ofFloat(flakeView, "y", startY, containerHeight + flakeSize) animY.setDuration(duration) animY.setInterpolator(LinearInterpolator()) local animX = ObjectAnimator.ofFloat(flakeView, "x", startX, startX + (containerWidth * windOffset / 100)) animX.setDuration(duration) -- 创建动画集合 local animSet = AnimatorSet() -- 根据概率决定是否添加旋转动画 if math.random() < snowConfig.rotationProbability then local rotation = math.random(snowConfig.minRotation, snowConfig.maxRotation) local animRotate = ObjectAnimator.ofFloat(flakeView, "rotation", 0, rotation) animRotate.setDuration(duration) animSet.playTogether(animY, animX, animRotate) else animSet.playTogether(animY, animX) end animSet.addListener({ onAnimationEnd = function() if isSnowActive then snowContainer.removeView(flakeView) snowFlakeCount = snowFlakeCount - 1 createSnowFlake(math.random(snowConfig.minDelay * 2, snowConfig.maxDelay * 2)) end end, onAnimationCancel = function() snowContainer.removeView(flakeView) snowFlakeCount = snowFlakeCount - 1 end }) animSet.start() end) end, delay or math.random(0, snowConfig.maxDelay * 2)) end -- 修改后的initSnowFlakes函数 local function initSnowFlakes() isSnowActive = true snowFlakeCount = 0 -- 改进7: 分批创建雪花时使用更大的随机延迟范围 local function createBatch(count, delay) Handler().postDelayed(function() if not isSnowActive then return end for i = 1, count do createSnowFlake(math.random(0, snowConfig.maxDelay * 3)) end end, delay or math.random(0, 500)) end local batches = math.ceil(snowConfig.flakeCount / 5) for i = 1, batches do createBatch(math.min(5, snowConfig.flakeCount - (i - 1) * 5), (i - 1) * 300) end end -- 清理雪花动画 local function clearSnowAnimation() isSnowActive = false snowFlakeCount = 0 snowContainer.removeAllViews() end -- 确保容器已测量后再初始化 snowContainer.post(function() initSnowFlakes() end) Handler(Looper.getMainLooper()) Looper.prepare() window.addView(ball, mainLayoutParams) change_menu(1) Looper.loop() end UI高度 =820 UI宽度 =1360 --getPic('http://wp.qimoyanzheng.com/static/logo.png') local icon = '/storage/emulated/0/神羽美化/图标.png' -- 悬浮窗图标, 写链接 namesy = '神羽美化'--项目名称 分页 = { [1]={ ['分区名字']='美化主页', ['分区logo']='/storage/emulated/0/神羽美化/图标.png', ['二级分页']={ [1]={ ['分页名字']='公告', ['分页logo']='/storage/emulated/0/神羽美化/图标.png', ['分页描述']='这里是分页描述', ['分页菜单']={ QingXu.Image("/storage/emulated/0/神羽美化/封面.jpg","145dp"), QingXu.button("选择进程",function() gg.setProcessX() end), QingXu.box({ "标题文字", -- 第一个元素必须是字符串或数字,作为标题 -- 后面可以添加任意数量的视图元素 QingXu.text("内容文本1"), QingXu.switch("开关1", function() gg.alert("开关1开启") end, function() gg.alert("开关1关闭") end), QingXu.text("内容文本2"), -- 可以继续添加更多视图... QingXu.checkbox({ { "自动瞄准", function() print("自动瞄准开启") end, function() print("自动瞄准关闭") end }, { "无限弹药", function() print("无限弹药开启") end, function() print("无限弹药关闭") end }, { "上帝模式", function() print("上帝模式开启") end, function() print("上帝模式关闭") end } }), }), } }, [2]={ ['分页名字']='公告2', ['分页logo']='/storage/emulated/0/神羽美化/图标.png', ['分页描述']='这里是分页描述', ['分页菜单']={ QingXu.seek("seek", "ltlz", 1, 100, 1), --名字,变量名字,最小,最大,初始 QingXu.switch('开关', function() local Y = gg.makeRequest("https://v1.hitokoto.cn/").content local text = string.match(Y, 'hitokoto(.+)type') text = string.gsub(text, '"[:,]"', "") gg.alert("今日语录:\n\n" .. text) end, function() gg.alert('开关关闭') end), } }, [3]={ ['分页名字']='公告3', ['分页logo']='/storage/emulated/0/神羽美化/图标.png', ['分页描述']='这里是分页描述', ['分页菜单']={ QingXu.seek("seek", "ltlz", 1, 100, 1), --名字,变量名字,最小,最大,初始 } }, [4]={ ['分页名字']='公告4', ['分页logo']='/storage/emulated/0/神羽美化/图标.png', ['分页描述']='这里是分页描述', ['分页菜单']={ QingXu.switch('开关', function() local Y = gg.makeRequest("https://v1.hitokoto.cn/").content local text = string.match(Y, 'hitokoto(.+)type') text = string.gsub(text, '"[:,]"', "") gg.alert("今日语录:\n\n" .. text) end, function() gg.alert('开关关闭') end), } }, } }, [2]={ ['分区名字']='参数美化', ['分区logo']='/storage/emulated/0/神羽美化/图标.png', ['二级分页']={ { ['分页名字']='参数', ['分页logo']='/storage/emulated/0/神羽美化/图标.png', ['分页描述']='这里是分页描述', ['分页菜单']={--直接写table的例子,看起来会比较乱 QingXu.switch('开关', function() gg.alert('开关开启') end, function() gg.alert('开关关闭') end), }, },{ ['分页名字']='测试', ['分页logo']='/storage/emulated/0/神羽美化/图标.png', ['分页描述']='测试页', ['分页菜单']={ }, } } }, [3]={ ['分区名字']='衣服美化', ['分区logo']='/storage/emulated/0/神羽美化/图标.png', ['二级分页']={ { ['分页名字']='衣服', ['分页logo']='/storage/emulated/0/神羽美化/图标.png', ['分页描述']='这里是分页描述', ['分页菜单']={ QingXu.switch('开关', function() gg.alert('开关开启') end, function() gg.alert('开关关闭') end), }, } } }, [4]={ ['分区名字']='功能功能', ['分区logo']='/storage/emulated/0/神羽美化/图标.png', ['二级分页']={ { ['分页名字']='功能', ['分页logo']='/storage/emulated/0/神羽美化/图标.png', ['分页描述']='这里是分页描述', ['分页菜单']={}, } } }, [5]={ ['分区名字']='脚本设置', ['分区logo']='/storage/emulated/0/神羽美化/图标.png', ['二级分页']={ { ['分页名字']='设置', ['分页logo']='/storage/emulated/0/神羽美化/图标.png', ['分页描述']='这里是分页描述', ['分页菜单']={ QingXu.switch('开关', function() gg.alert('开关开启') end, function() gg.alert('开关关闭') end), }, } } }, } -- 图标,标题,菜单 QingXu.menu(icon, title, 分页)