YYRMM的软件库 YYRMM's Software Library
🎀

绪心桌宠 v1.4.0

Xuxin Desktop Pet v1.4.0

安卓悬浮窗上的程序化桌宠 · 三套角色全靠代码逐像素画出来(2026-10-31 更新)

A procedurally drawn desktop pet for Android — three characters painted pixel by pixel in code (updated 2026-10-31)

Android 8.0+ Kotlin v1.4.0 程序化建模 Procedural Art 约 3.6 MB about 3.6 MB MIT

软件介绍

About

绪心桌宠是一款跑在安卓手机上的桌宠:像电脑桌宠那样悬浮在桌面最上层,随时陪着你。它不依赖 Live2D、也不加载任何 3D 模型——三套角色(初音未来 / 洛天依 / 乐正绫)全部由 Canvas 程序化建模 + 骨骼动画逐像素绘制,随包只有一个 APK,约 3.6 MB(R8 混淆 + 资源收缩)。

角色都按 3 头身 Q 版建模:蛋形头、发丝分层高光、渐变眼珠、腮红、小手小鞋,初音的面部还做了透明挖空,悬浮在桌面上时直接透出壁纸。骨骼层级写成显式状态机 —— 待机时呼吸起伏、漂浮与眨眼,行走时双腿交替迈步并反向摆臂、朝向随移动翻转,被拎起时悬垂摆动,开心与困倦则由心情 / 饱食度状态驱动。

陪伴系统是它和「一张会动的图」的区别:点击与投喂都有气泡和语音反馈(系统离线 TTS,没有引擎时静默降级为气泡),双击触发爱心爆发与弹跳,启动时按早 / 午 / 晚 / 深夜问候;心情与饱食度会随互动提升、闲置衰减并存进本地;久坐与喝水提醒走独立的高优先级通知通道(响铃 + 震动),点通知直达主界面;今日陪伴时长、互动次数与投喂次数跨重启累计,桌面小组件上也能看到。

最新版本 V1.4.0 是一次纯优化迭代,不改造型,专治三个真问题:长时间挂机的耗电(动画出帧上限 60fps,高刷屏不再按 120Hz 全速重绘,熄屏或窗口不可见时暂停自刷新)、今日陪伴时长恒为 0(统计入口此前没有调用方,现在由前台服务按分钟批量累加)、以及久坐 / 喝水提醒不响(此前复用常驻通知的低优先级通道,现在独立通道 + 震动 + 角标)。

说明:初音未来 / 洛天依 / 乐正绫为他人版权角色,本项目仅作个人学习与练习用途;仓库暂未提供预编译 APK,按 README 用 Android Studio / Gradle 自行构建即可(compileSdk 34、minSdk 24)。

Xuxin Desktop Pet is a desktop pet that lives on an Android phone: it floats above the home screen, the way a PC desktop pet would. It uses no Live2D and loads no 3D models — all three characters (Hatsune Miku, Luo Tianyi and Yue Zhengling) are painted pixel by pixel with Canvas procedural modelling plus skeleton animation, shipped as a single ~3.6 MB APK (R8 shrinking and resource reduction).

Each character is modelled in a 3-head-tall chibi style: egg-shaped head, layered hair highlights, gradient irises, blush, little hands and shoes — and Miku's face is cut out transparent so the wallpaper shows straight through. The skeleton runs an explicit state machine: breathing, floating and blinking while idle; alternating legs, counter-swinging arms and a direction-aware flip while walking; dangling when picked up; and happy or sleepy expressions driven by the mood and hunger systems.

The companionship layer is what separates it from an animated picture: taps and feeding produce both a bubble and speech (the system's offline TTS, degrading silently to bubbles when no engine exists), a double tap triggers a heart burst and a bounce, and startup greets you by time of day. Mood and hunger rise with interaction and decay while idle, persisted locally. Sit and water reminders use their own high-priority notification channel (sound plus vibration) that opens the main screen when tapped, and today's companionship time, interactions and feedings accumulate across restarts — visible on the home-screen widget too.

The latest release, V1.4.0, is a pure optimisation pass with no character changes, aimed at three real problems: battery drain during long sessions (a 60 fps frame cap so 120 Hz screens stop redrawing at full speed, and self-refresh paused when the screen is off or the window is hidden), companionship time stuck at zero (the counter had no caller; the foreground service now accumulates it by the minute) and reminders that never rang (they reused the low-importance persistent channel; they now have their own channel with vibration and a badge).

Note: Miku, Luo Tianyi and Yue Zhengling are characters owned by others, and this project is for personal study and practice only. The repository does not ship a prebuilt APK — build it with Android Studio / Gradle as described in the README (compileSdk 34, minSdk 24).

功能特性

Features

三套程序化角色初音未来 / 洛天依 / 乐正绫,全部 Canvas 逐像素绘制:蛋形头、品红耳机、渐变眼珠、腮红、勺形双马尾、裙装与飘带,无图片素材、无 Live2D
Three procedural charactersMiku, Luo Tianyi and Yue Zhengling, all drawn pixel by pixel on Canvas — egg-shaped head, magenta headset, gradient irises, blush, scoop-shaped twin tails, dresses and ribbons, with no image assets and no Live2D
骨骼动画状态机待机(呼吸 / 漂浮 / 眨眼 / 发束摆动)、行走(交替迈步 + 反向摆臂 + 朝向翻转)、拖拽(悬垂摆动)、开心(弹跳举手)、困倦(闭眼慢呼吸)
Skeleton state machineIdle (breathing, floating, blinking, swaying hair), walk (alternating steps, counter-swinging arms, direction flip), drag (dangling), happy (bounce and raised hands) and sleepy (closed eyes, slow breathing)
互动与语音单击随机萌语气泡、饥饿时点击自动投喂、双击爱心爆发 ×5;系统离线 TTS 让宠物「开口说话」,无引擎时静默降级为气泡
Interaction and voiceRandom cute bubbles on tap, automatic feeding when hungry, a five-heart burst on double tap; offline system TTS lets the pet talk, degrading silently to bubbles when no engine exists
心情与饱食度养成互动提升、闲置衰减,结果持久化;状态反过来驱动表情与动画,饿了会提醒你投喂
Mood and hunger systemsInteraction raises them, idling decays them, and both persist — the state then drives expressions and animation, telling you when it's hungry
久坐 / 喝水提醒(V1.4.0 修复)前台服务内调度,独立高优先级通知渠道带响铃、震动与角标;点通知直达主界面
Sit and water reminders (fixed in V1.4.0)Scheduled inside the foreground service on their own high-priority channel with sound, vibration and a badge; tapping the notification opens the main screen
陪伴统计(V1.4.0 落盘)今日陪伴时长按分钟批量累加,互动与投喂次数一并记录,跨重启累计,主界面与小组件同步显示
Companionship stats (persisted in V1.4.0)Today's time accumulates per minute alongside interaction and feeding counts, survives restarts, and shows on both the main screen and the widget
悬浮窗与小组件窗口约屏幕短边 32%、自动贴边隐藏,长按迷你菜单可换形象 / 设置 / 退出陪伴;右上角陪伴小窗与桌面小组件(心情 / 饱食 / 今日陪伴,30 分钟刷新)
Overlay and widgetThe window is about 32% of the screen's short edge and snaps to the edge to hide; a long-press mini menu swaps characters or opens settings. Plus a companion mini window and a home-screen widget (mood / hunger / today's time, refreshed every 30 minutes)
省电渲染(V1.4.0)动画出帧上限 60fps,超过 14ms 的重复帧直接跳过;熄屏或窗口不可见时停止自刷新,回到前台立即恢复;陪伴小窗每秒刷新只读内存态,不再每秒写盘
Battery-friendly rendering (V1.4.0)A 60 fps frame cap with repeated frames over 14 ms skipped; self-refresh stops when the screen is off or the window hidden and resumes instantly; the mini window reads memory state instead of writing to disk every second
数据与备份心情 / 饱食 / 统计 / 设置存 SharedPreferences,支持导出与恢复 JSON 备份(带类型校验,坏备份不会让程序崩)
Data and backupMood, hunger, stats and settings live in SharedPreferences, with JSON backup export and restore (type-checked, so a corrupt backup can't crash the app)
轻量与可验证APK 约 3.6 MB;状态机是纯 Kotlin 可单测的部分(10 项状态机用例),release 启用 R8 与正式签名,避免手机不认安装包
Small and testableA ~3.6 MB APK; the state machine is pure Kotlin with 10 unit-test cases, and release builds use R8 with a real signing key so phones accept the package

项目档案

Project Details

Platform
Android 8.0+(minSdk 24 / targetSdk 33 / compileSdk 34),需要「显示在其他应用上层」权限
Android 8.0+ (minSdk 24 / targetSdk 33 / compileSdk 34); needs the "display over other apps" permission
Stack
Kotlin(JVM 1.8)+ ViewBinding;自定义 View 绘制(PetCharacterView / AnimeGirlView)、前台服务、AppWidget、离线 TTS
Kotlin (JVM 1.8) with ViewBinding; custom views (PetCharacterView / AnimeGirlView), a foreground service, AppWidget and offline TTS
Rendering
Canvas 程序化建模 + 显式骨骼层级(肩→肘→手 / 髋→膝→脚 / 脊柱),骨骼角度每帧由时间函数驱动;无图片素材、无 Live2D、无 3D 模型
Canvas procedural modelling with an explicit bone hierarchy (shoulder→elbow→hand, hip→knee→foot, spine), bone angles driven by time functions each frame — no image assets, no Live2D, no 3D models
Permissions
只申请悬浮窗、前台服务与通知所需权限;无网络权限,互动、语音与统计全在本机完成
Only the overlay, foreground-service and notification permissions; no network permission — interaction, voice and stats all stay on device
Build
Gradle Kotlin DSL;gradlew.bat assembleRelease 出正式签名包(需按 keystore/README.md 配置密钥),gradlew test 跑状态机单测
Gradle Kotlin DSL; gradlew.bat assembleRelease produces a signed build (configure keys per keystore/README.md), gradlew test runs the state-machine tests
License
MIT

更新记录

Changelog

← 返回软件列表 ← Back to software list