home / skills / hoangnguyen0403 / agent-skills-standard / xml-views
This skill enforces Android XML View standards by advocating ViewBinding, RecyclerView with ListAdapter, and efficient Layouts to boost app reliability.
npx playbooks add skill hoangnguyen0403/agent-skills-standard --skill xml-viewsReview the files below or copy the command above to add this skill to your agents.
---
name: Android XML Views
description: Standards for ViewBinding, RecyclerView, and XML Layouts
metadata:
labels: [android, xml, views, viewbinding]
triggers:
files: ['layout/*.xml', '**/*Binding.java', '**/*Binding.kt']
keywords: ['ViewBinding', 'ConstraintLayout', 'RecyclerView']
---
# Android XML Views Standards
## **Priority: P1**
## Implementation Guidelines
### ViewBinding
- **Standard**: Use ViewBinding for all XML layouts.
- **Synthetics**: `kotlin-android-extensions` is Dead. Remove it.
- **KAPT**: Avoid DataBinding unless strictly necessary (impacts build speed).
### RecyclerView
- **Adapter**: Always inherit `ListAdapter` (wraps AsyncListDiffer).
- **Updates**: Provide a proper `DiffUtil.ItemCallback`. NEVER call `notifyDataSetChanged()`.
### Layouts
- **ConstraintLayout**: Use for complex flat hierarchies.
- **Performance**: Avoid deep nesting (LinearLayout inside LinearLayout).
## Anti-Patterns
- **findViewById**: `**Deprecated**: Use ViewBinding.`
- **Synthetics**: `**Deprecated**: Remove import kotlinx.android.synthetic.*.`
## References
- [ViewBinding & Adapter](references/implementation.md)
This skill documents standards for Android XML views, focusing on ViewBinding, RecyclerView usage, and XML layout best practices. It defines clear rules to improve runtime performance, reduce build-time friction, and enforce maintainable UI code. The guidance targets Kotlin Android projects and complements adapters, diffing, and layout choices.
The skill inspects UI layer patterns and recommends replacing deprecated APIs and anti-patterns with modern alternatives. It enforces ViewBinding for all XML layouts, prescribes ListAdapter with DiffUtil for RecyclerView adapters, and promotes ConstraintLayout for flat, performant view hierarchies. It also flags legacy synthetics and findViewById usages for removal.
Why avoid kotlin-android-extensions synthetics?
Synthetics are deprecated, break module boundaries, and can cause obscure runtime issues; ViewBinding is safer and type-safe.
When is DataBinding acceptable?
Use DataBinding only when you need two-way binding or complex expression logic in XML and the benefits outweigh slower build times.