跳到正文
Skillpedia
网站与界面(前端)10k · #11941

display-glasses-with-jetpack-compose-glimmer

它能做什么

这个技能提供在显示眼镜上展示内容的 Android XR 应用的指导原则,使用 Jetpack Compose Glimmer 工具包。涵盖设计原则、工作流程和眼镜上的交互方式。适合在智能眼镜上开发一目了然体验的 Android 开发者。

适用场景

  • ✓你想构建在显示眼镜上展示一目了然内容的 Android XR 应用的时候。
  • ✓你需要为眼镜界面使用 Glimmer 主题和组件的时候。
  • ✓你想规划显示眼镜体验的文字大小和布局的时候。

技能链接

https://github.com/android/skills/blob/main/xr/display-glasses-with-jetpack-compose-glimmer/SKILL.md

复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。

使用方法

最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/android/skills/blob/main/xr/display-glasses-with-jetpack-compose-glimmer/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 AI

“请帮我用 Compose Glimmer 构建一个简单的 Android XR 应用,在显示眼镜上显示我的下一场会议。”

每周 5 个新技能,1 分钟读完。

工作原理

这个技能会设置投屏 Activity 并检查目标 SDK,然后应用 Glimmer 主题和组件。它遵循眼镜设计原则,保证文字易读,并以焦点为基础进行交互。

技术内容(原始 SKILL.md)

作者在 GitHub 上的英文原文。

Glossary

Term Definition
Intelligent eyewear Hands-free eyewear with speakers, camera, and microphone (audio-only or display glasses).
Display glasses Eyewear with a private in-lens display for glanceable visuals that pair with audio.
Jetpack Compose Glimmer Compose UI toolkit providing components, theming, and focus behavior for display glasses.
Projected activity An Activity running on a phone host whose UI and input are projected to connected eyewear.
Projected device An XR eyewear device connected to an Android host phone that projects app content to it.
GlimmerTheme Root styling provider for GlimmerColors, GlimmerTypography, and GlimmerShapes.
Additive display Display where black (#000000) renders as 100% transparent by adding light to the scene.
Augmented experiences Lightweight, additive Android XR experiences that help users while they're on the go.
Visual angle Perceived size in XR; minimum readable text is 0.6 degrees (about 18sp at 1 m).

Prerequisites

  • Target compileSdk 37 or higher (compileSdk = 37 or compileSdk { version = release(37) }). Update compileSdk to 37 if lower.
  • When adding dependencies, follow the instructions in Create your first activity for intelligent eyewear:
    • androidx.xr.glimmer:glimmer (minimum 1.0.0-alpha21, or catalog alias libs.androidx.glimmer)
    • androidx.xr.glimmer:glimmer-google-fonts (minimum 1.0.0-alpha21, or catalog alias libs.androidx.glimmer.google.fonts)
    • androidx.xr.projected:projected (minimum 1.0.0-alpha13, or catalog alias libs.androidx.xr.projected or libs.androidx.projected)
    • Check gradle/libs.versions.toml first; if catalog entries exist, use them in app/build.gradle.kts and verify their versions meet the minimums. Never guess 1.0.0-alpha01 for glimmer-google-fonts.

Core constraints and limitations

  • Don't : Use MaterialTheme or Material 3 components (androidx.compose.material3.*) inside Projected Activities or Glimmer UI.
  • Do : Use GlimmerTheme and Glimmer components (androidx.xr.glimmer.*).
  • Do : Always pass createGoogleSansFlexTypography() from androidx.xr.glimmer.googlefonts as typography in GlimmerTheme.
  • Specific hardware device models or unique capabilities aren't detailed.
  • Elevation : Material 3 shadow or elevation modifiers aren't supported. Use ShadowScope or Depth tokens from Jetpack Compose Glimmer.
  • Typography limits: Minimum readable text size is 18sp (0.6°). Avoid "Thin" or "Hairline" weights, which shimmer on additive lenses.

1. Set up dependencies

  • Set up projected activity : When creating a projected activity, follow Create your first activity for intelligent eyewear and projectedcontext-source.md. Set android:requiredDisplayCategory to android.hardware.display.category.XR_PROJECTED in AndroidManifest.xml:

    <activity
        android:name="com.example.xr.projected.ProjectedMainActivity"
        android:exported="true"
        android:requiredDisplayCategory="android.hardware.display.category.XR_PROJECTED">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.XR_PROJECTED_LAUNCHER"/>
        </intent-filter>
    </activity>
    
    <br />
  • Mobile app integration : In the host phone app, add a button with Text("Launch on Glasses"). Observe ProjectedContext.isProjectedDeviceConnected(context, coroutineContext) using collectAsStateWithLifecycle(initialValue = false) to set the button's enabled state so it's disabled when glasses are disconnected. When clicked, launch GlassesMainActivity on the glasses display using ProjectedContext.createProjectedActivityOptions(context).toBundle() as shown in the following snippet:

    val options = ProjectedContext.createProjectedActivityOptions(context)
    val intent = Intent(context, ProjectedMainActivity::class.java)
    context.startActivity(intent, options.toBundle())
    
    <br />
  • UI library and font : When declaring the Glimmer, Google Fonts, and Projected artifacts in app/build.gradle.kts, follow [Declaring Jetp

常见问题

需要哪个编译 SDK?

项目必须以 compileSdk 37 或更高版本为目标,如果较低,这个技能会将其提高。

它适用于纯音频眼镜吗?

不适用。这个技能面向有显示屏的眼镜,没有显示屏的纯音频 AI 眼镜不在范围内。

什么是投屏 Activity?

它是在手机上运行、并把界面显示到已连接眼镜上的 Activity。

详情

作者的原始描述

Provides guidelines for developing projected Android XR apps for display glasses using the Jetpack Compose Glimmer UI toolkit. Covers Glimmer design principles, workflows, and interaction models for the glasses form factor. Use this skill to build an Android XR Augmented Experience app with Jetpack Compose Glimmer. Don't use for audio-only AI glasses without a display, non-glasses Android XR headsets (spatial panels or 3D volumes with Jetpack Compose for XR), or phone and tablet Material 3 UIs.

repo: android/skills

热度

GitHub 星标
10k
排名
#11941
许可证
Apache-2.0
更新时间
2026/10/29

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能