android-custom-icons

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Android Custom PNG Icons

Android自定义PNG图标

Use custom PNG icons in Android apps instead of icon libraries. Whenever UI code includes an icon, the agent must use a PNG placeholder and update
PROJECT_ICONS.md
so the icon list is tracked for later upload.
在Android应用中使用自定义PNG图标而非图标库。每当UI代码中包含图标时,必须使用PNG占位符并更新
PROJECT_ICONS.md
,以便后续上传时跟踪图标列表。

Scope

适用范围

Use for: All Android UI generation (Compose and XML).
Do not use: Material Icons, Font Awesome, or any bundled icon libraries unless the user explicitly asks for them.
适用场景: 所有Android UI生成(Compose和XML)。
禁止使用: Material Icons、Font Awesome或任何捆绑图标库,除非用户明确要求。

Standard Icon Directory

标准图标目录

  • Primary location:
    app/src/main/res/drawable/
  • If you need 1:1 pixels (no scaling):
    app/src/main/res/drawable-nodpi/
If multiple densities are provided later, place them in
drawable-hdpi
,
drawable-xhdpi
,
drawable-xxhdpi
,
drawable-xxxhdpi
using the same file name.
  • 主位置:
    app/src/main/res/drawable/
  • 如果需要1:1像素(不缩放):
    app/src/main/res/drawable-nodpi/
如果后续提供多种密度的图标,请将它们放在
drawable-hdpi
drawable-xhdpi
drawable-xxhdpi
drawable-xxxhdpi
目录下,使用相同的文件名。

File Naming Rules (Required)

文件命名规则(必填)

  • Lowercase letters, numbers, underscores only
  • No hyphens, no spaces, no uppercase
  • File name becomes
    R.drawable.<name>
Examples:
  • cancel.png
    ->
    R.drawable.cancel
  • chart.png
    ->
    R.drawable.chart
  • filter.png
    ->
    R.drawable.filter
  • 仅使用小写字母、数字、下划线
  • 不得使用连字符、空格、大写字母
  • 文件名对应
    R.drawable.<name>
示例:
  • cancel.png
    ->
    R.drawable.cancel
  • chart.png
    ->
    R.drawable.chart
  • filter.png
    ->
    R.drawable.filter

Compose Usage (Required)

Compose使用规范(必填)

kotlin
Icon(
    painter = painterResource(R.drawable.cancel),
    contentDescription = "Cancel",
    modifier = Modifier.size(24.dp)
)
kotlin
Image(
    painter = painterResource(R.drawable.chart),
    contentDescription = null,
    modifier = Modifier.size(48.dp)
)
kotlin
Icon(
    painter = painterResource(R.drawable.cancel),
    contentDescription = "Cancel",
    modifier = Modifier.size(24.dp)
)
kotlin
Image(
    painter = painterResource(R.drawable.chart),
    contentDescription = null,
    modifier = Modifier.size(48.dp)
)

XML Usage (Required)

XML使用规范(必填)

xml
<ImageView
    android:layout_width="24dp"
    android:layout_height="24dp"
    android:src="@drawable/cancel"
    android:contentDescription="@string/cancel" />
xml
<ImageView
    android:layout_width="24dp"
    android:layout_height="24dp"
    android:src="@drawable/cancel"
    android:contentDescription="@string/cancel" />

PROJECT_ICONS.md (Required)

PROJECT_ICONS.md(必填)

Maintain a
PROJECT_ICONS.md
file at the project root. Every time code introduces a new icon placeholder, append a row.
项目根目录维护一个
PROJECT_ICONS.md
文件。每当代码中引入新的图标占位符时,添加一行记录

Template

模板

markdown
undefined
markdown
undefined

Project Icons

Project Icons

Standard path: app/src/main/res/drawable/
Icon FileUsageScreen/ComponentStatusNotes
cancel.pngClose actionEditProfileTopBarplaceholderProvide 24dp PNG
undefined
Standard path: app/src/main/res/drawable/
Icon FileUsageScreen/ComponentStatusNotes
cancel.pngClose actionEditProfileTopBarplaceholderProvide 24dp PNG
undefined

Update Rules

更新规则

  • Add a row every time a new icon placeholder is referenced in code.
  • Use the exact file name used in code (e.g.,
    cancel.png
    ).
  • Keep status as
    placeholder
    until the PNG is provided.
  • 每当代码中引用新的图标占位符时,添加一行记录。
  • 使用代码中确切的文件名(例如
    cancel.png
    )。
  • 在PNG图标提供前,状态保持为
    placeholder

Mandatory Checklist (Per UI Generation)

强制检查清单(每次UI生成时)

  • Use PNG placeholders only (no icon libraries)
  • Use
    painterResource(R.drawable.<name>)
    or
    @drawable/<name>
  • Add or update
    PROJECT_ICONS.md
  • Placeholders use valid Android resource naming
  • 仅使用PNG占位符(不使用图标库)
  • 使用
    painterResource(R.drawable.<name>)
    @drawable/<name>
  • 添加或更新
    PROJECT_ICONS.md
  • 占位符使用有效的Android资源命名规则