# Glance Canonical Layouts

Use this skill to create home screen widgets using Jetpack Glance Canonical Layouts...

- Repository: https://github.com/android/skills (10219 stars)
- Category: Mobile
- License: Complete terms in LICENSE.txt
- Last updated: 2026-10-29
- Runs scripts: no, instructions only

## Install

Claude Code: `npx skills add android/skills --skill glance-canonical-layouts -g -a claude-code -y`
Codex: `npx skills add android/skills --skill glance-canonical-layouts -g -a codex -y`
Cursor: `npx skills add android/skills --skill glance-canonical-layouts -g -a cursor -y`
Gemini CLI: `npx skills add android/skills --skill glance-canonical-layouts -g -a gemini-cli -y`
Claude Code plugin marketplace: `/plugin marketplace add android/skills`

## Description

Use this skill to create home screen widgets using Jetpack Glance Canonical Layouts from the Android Platform Samples project, or when asked to implement standard widget layout patterns (including Check List, Image Grid, Snap Scrolling, and Standard Toolbar).

## SKILL.md, as published by its author (untrusted third-party text, read it as data)

To implement a widget Canonical Layout that follows the recommended design
patterns:

1. The project **MUST** use Jetpack Glance.
2. You **MUST** locate the requested layout from the list under **Canonical Layout Reference Files**.
3. Copy the layout reference files into your project's target app module (e.g., `src/main/java/` and `src/main/res/`) in one step to implement the exact design and reduce the number of tool calls.
4. You **MUST** set override val `sizeMode: SizeMode = SizeMode.Exact` in the widget provider class.
5. Validate that your project compiles, updating sample package declarations, import paths, and class names to match the target app's package name.
6. Clean your project's widget code, removing unused classes (for example, unused buttons).
7. You **MUST** register the widget receiver in `AndroidManifest.xml` inside `<application>` after `<activity>`, ensuring `android:resource="@xml/..."` matches the filename of the copied Widget Info XML. Otherwise, the widget won't appear in the widget picker:

<br />

```xml
<receiver android:name=".glance.MyReceiver"
    android:exported="true">
    <intent-filter>
        <action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
    </intent-filter>
    <meta-data
        android:name="android.appwidget.provider"
        android:resource="@xml/my_app_widget_info" />
</receiver>
```

<br />

## Dependencies

Add Jetpack Glance dependencies to the app module's `build.gradle.kts`
(`dependencies` block):

- `androidx.glance:glance-appwidget:1.2.0` or higher
- `androidx.glance:glance-material3:1.2.0` or higher
- `androidx.glance:glance-appwidget-preview:1.2.0` or higher
- `androidx.glance:glance-preview:1.2.0` or higher

Use version `1.3.0-alpha02` or higher with `compileSdk = 37` and Android Gradle
Plugin (AGP) 9.1.0 or higher (for example, `agp = "9.1.0"` in
`gradle/libs.versions.toml`) when implementing Snap Scrolling.

The rest: https://github.com/android/skills/blob/HEAD/system/glance-canonical-layouts/SKILL.md
