home / skills / hoangnguyen0403 / agent-skills-standard / resources

resources skill

/skills/android/resources

This skill helps enforce Android resource and localization best practices by guiding string usage in XML, vector drawables, and dark mode theming.

npx playbooks add skill hoangnguyen0403/agent-skills-standard --skill resources

Review the files below or copy the command above to add this skill to your agents.

Files (2)
SKILL.md
993 B
---
name: Android Resources & Localization
description: Standards for Strings, Drawables, and Localization
metadata:
  labels: [android, resources, localization, xml]
  triggers:
    files: ['strings.xml', '**/*Screen.kt']
    keywords: ['stringResource', 'plurals', 'R.string']
---

# Android Resources Standards

## **Priority: P2**

## Implementation Guidelines

### Strings

- **No Hardcoding**: UI text MUST be in `strings.xml`.
- **Formatting**: Use format args (`%s`, `%d`) instead of concatenation.
- **Plurals**: Use `<plurals>` for quantities.

### Assets / Drawables

- **Vectors**: Prefer VectorDrawables (`.xml`) over RASTER images.
- **Dark Mode**: Use `values-night` or Theme attributes (`MaterialTheme.colorScheme.primary`) instead of hardcoded colors.

## Anti-Patterns

- **Concatenation in UI**: `**No String Concat**: Use resource templates.`
- **Hardcoded Strings**: `**No hardcoded text**: Extract to XML.`

## References

- [XML Structure](references/implementation.md)

Overview

This skill documents standards for Android resources and localization to ensure consistent, maintainable UI text and assets. It focuses on string management, formatting, pluralization, drawable choices, and dark mode handling. The goal is to reduce bugs, improve translation workflows, and enforce reusable resource patterns.

How this skill works

The skill inspects code and resource files to verify that UI text is defined in strings.xml, that format arguments and plurals are used where appropriate, and that no hardcoded strings appear in layouts or code. It checks drawable usage to prefer VectorDrawables over raster images and enforces night-mode resource or theme-based color usage instead of hardcoded colors. The skill flags common anti-patterns like string concatenation in UI and missing plural resources.

When to use it

  • During code reviews to catch localization and resource issues early.
  • When preparing an app for translation or internationalization.
  • During UI refactors to centralize text and color definitions.
  • When optimizing app size and supporting multiple screen densities.
  • Before release to ensure dark mode and pluralization behave correctly.

Best practices

  • Never hardcode UI text in layouts or code; place all user-facing strings in strings.xml.
  • Use format args (%s, %d) in string resources instead of concatenating text in code or XML.
  • Declare quantities with <plurals> to handle language-specific plural rules correctly.
  • Prefer VectorDrawable (.xml) for icons and simple graphics to reduce APK size and scale cleanly.
  • Support dark mode using values-night resources or theme attributes rather than hardcoded color literals.
  • Centralize colors and styles in themes so components inherit correct values across configurations.

Example use cases

  • Static analysis rule that fails builds when string literals appear in layout XML or activity classes.
  • Lint check to ensure string resources using placeholders match the number and type of format args in code.
  • Automated audit that recommends converting PNG icons to VectorDrawable where safe.
  • Pull request checklist item ensuring plurals are added for text that depends on quantity.
  • Theme migration task that replaces hardcoded color references with theme attributes for dark mode support.

FAQ

What if a string contains both dynamic data and fixed text?

Use a string resource with format args (e.g., "Welcome, %1$s") and supply values from code to avoid concatenation and enable translations.

When should I use a raster image instead of a VectorDrawable?

Use raster images for complex artwork or photos where vectors are impractical; prefer vectors for icons and simple UI graphics to save size and ensure sharp scaling.