本文へスキップ
Skillpedia
モバイルアプリ10k · #11936

glance-canonical-layouts

できること

このスキルは、Androidのサンプルプロジェクトから、標準的なウィジェットのレイアウトをあなたのアプリにコピーします。Jetpack Glanceを使います。レイアウトには、チェックリスト、画像のグリッド、スナップスクロール、標準のツールバーが含まれます。ホーム画面のウィジェットを作るAndroid開発者向けです。

使う場面

  • ✓チェックリストや画像のグリッドを持つホーム画面のウィジェットがほしいとき。
  • ✓Androidアプリに、標準のウィジェットのツールバーやスナップスクロールのレイアウトが必要なとき。
  • ✓新しいウィジェットがウィジェットピッカーに表示されず、その登録を確認する必要があるとき。

スキルのリンク

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

コピーしてAI(Claude、ChatGPT、Cursor)に貼り付け、指示に従うよう頼んでください。

使い方

いちばん簡単な方法:メッセージをコピーしてAIに貼り付けるだけ。AIがスキルを読んで指示に従います。

貼り付け用メッセージ

このスキルを使って手伝ってください:https://github.com/android/skills/blob/main/system/glance-canonical-layouts/SKILL.md このリンクのSKILL.mdファイルを読んで、私の作業でその指示に従ってください。
こういうスキルを、AIが自分で見つけてくれたら?無料のSkillpedia MCPをインストール。1行で、作業の前に15,000+のスキルから探してくれます。1分でインストール →

AIへの頼み方の例

“標準のGlanceレイアウトを使って、Androidアプリにチェックリストのウィジェットを追加してください。”

毎週5つの新しいスキル。1分で読めます。

仕組み

このスキルは、選んだレイアウトの参照ファイルをアプリにコピーし、パッケージ名とインポートを更新します。未使用の部分を取り除き、ウィジェットのレシーバーをマニフェストに登録して、ピッカーに表示されるようにします。

技術的な内容(元のSKILL.md)

作者による元のテキスト(英語)をGitHubからそのまま表示しています。

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 />
<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.

If copying sample data repositories that load bitmaps with Coil (such as FakeImageGridDataRepository.kt, FakeImageTextListDataRepository.kt, or FakeTextWithImageRepository.kt), also add an image loading library dependency such as io.coil-kt:coil (e.g., implementation("io.coil-kt:coil:2.7.0")) if one doesn't already exist.

Canonical layout reference files

Action list layout (action_list)

よくある質問

なぜウィジェットがピッカーに表示されないのですか?

レシーバーは、対応するウィジェットの情報ファイルとともにマニフェストに登録されている必要があり、このスキルがそれを確認します。

Jetpack Glanceが必要ですか?

はい。これらのレイアウトを使うには、プロジェクトがJetpack Glanceを使っている必要があります。

どのサイズのモードを使いますか?

このスキルは、ウィジェットのプロバイダークラスでサイズのモードをexactに設定します。

詳細

作者による元の説明

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).

repo: android/skills

人気

GitHubのスター
10k
ランキング
#11936
ライセンス
Apache-2.0
更新日
2026/10/29

このスキルは役に立ちますか?

0

ログイン して投票しましょう。

コメント

  • …

このリポジトリの他のスキル

似ているスキル