android-layouts
Android layout best practices for XML/Views and Jetpack Compose.
Skill by kvithayathil
Install
Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.
npx agentmarket install skill/kvithayathil-android-layouts
Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.
Get the weekly diff
The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.
About
Reviews
Write a reviewNo reviews yet. Installed it? Reviews come from verified installers only. How reviews work
Permissions
What this skill can do and what it asks for, from its SKILL.md. Checked Oct 25, 2026.
- Tools
- No tools found
- Secrets
- None asked for
- Install scripts
- None found
Network hosts it talks to 1
codeload.github.com· found in install command
Files it touches
~/.claude/skills/android-layouts
What's inside
- Skill name
android-layouts- Description
- Android layout best practices for XML/Views and Jetpack Compose. Covers hierarchy flattening, ConstraintLayout, merge/include, ViewStub, Compose layout phases, interop between View and Compose, adaptive layouts, and profiling tools. Use when creating, reviewing, or optimizing Android layouts in XML or Compose. Trigger on: layout, XML, ConstraintLayout, LinearLayout, RecyclerView, merge, include, ViewStub, compose layout, layout phases, LazyColumn, adaptive layout, WindowSizeClass, foldable, Layout Inspector, lint, profiling, hierarchy, double taxation, interop, AndroidView, ComposeView, modifier order, WindowInsets, contentPadding, Scaffold, CoordinatorLayout, ViewPager2, HorizontalPager, Material 3.
- License
- Apache-2.0
- Metadata
- author: kvithayathil · living: true · version: 1.1.0 · last-reviewed: 2026-04-24 · self-learning: true · self-updating: true · update-policy: evolve-on-evidence
- Instructions
- 285 lines in SKILL.md · view on GitHub
Files (8)
- SKILL.md
- CHANGELOG.md · references/
- COMPOSE_LAYOUTS.md · references/
- INTEROP.md · references/
- LESSONS_LEARNED.md · references/
- MATERIAL_DESIGN.md · references/
- PROFILING_TOOLS.md · references/
- XML_LAYOUTS.md · references/
SKILL.md (first lines)
# Android Layout Best Practices
Layout performance and structure guidance for XML/View systems and Jetpack Compose.
For Compose-specific concerns (stability, recomposition, side effects, animations, modifier
extensions), use the **android-compose-ui** skill. This skill focuses on layout hierarchy,
structure, and performance.
## Reference Index
| File | Topics |
|------|--------|
| [XML_LAYOUTS.md](references/XML_LAYOUTS.md) | ConstraintLayout, merge/include, ViewStub, double taxation, RecyclerView, CoordinatorLayout, ViewPager2, WindowInsets |
| [COMPOSE_LAYOUTS.md](references/COMPOSE_LAYOUTS.md) | Layout phases, custom layouts, SubcomposeLayout, modifier order, WindowInsets, contentPadding, HorizontalPager |
| [INTEROP.md](references/INTEROP.md) | View-to-Compose migration, AndroidView, ComposeView |
| [MATERIAL_DESIGN.md](references/MATERIAL_DESIGN.md) | Scaffold, TopAppBar, NavigationBar/Rail, drawers, inset contracts |
| [PROFILING_TOOLS.md](references/PROFILING_TOOLS.md) | Layout Inspector, Lint, Perfetto, benchmarking |
| [LESSONS_LEARNED.md](references/LESSONS_LEARNED.md) | Self-learning log |
| [CHANGELOG.md](references/CHANGELOG.md) | Update history |
---
## Core Principle
**Flat hierarchies are fast hierarchies.** Every widget in the tree pays init + measure + layout +
draw cost. Each nesting level multiplies that cost across all children. The single most impactful
layout optimization is reducing depth.
---
## XML Layout Rules
### Hierarchy Depth
- Target **max 10 levels** of nesting. Profile anything deeper.
- Replace nested `LinearLayout` (especially weighted) with a single `ConstraintLayout`.
- Use `<merge>` as root tag when the layout will be included in another — eliminates one
nesting level.
- Use `<include>` to reuse layout fragments; combine with `<merge>` for zero-overhead inclusion.
### Double Taxation
Some layout containers measure children multiple times:
| Container | Double Measure? | Why |
|-----------|-----------------|-----|
| `LinearLayout` with weights | Yes | Weight distribution requires pre-measure |
| `RelativeLayout` | Yes | Constraints may reference each other |
| `GridLayout` with weights | Yes | Same as LinearLayout weights |
| `ConstraintLayout` | No | Single-pass constraint solver |
**Rule:** If a container triggers double measurement, replace it with `ConstraintLayout` or
restructure to avoid the multi-pass trigger.
### ViewStub
Use `ViewStub` for layouts that are rarely or conditionally visible (error states, empty states,
progress indicators). `ViewStub` is a zero-dimension placeholder that inflates the real layout
only when `setVisibility(VISIBLE)` or `inflate()` is called.
```xml
<ViewStub
android:id="@+id/stub_error"
android:layout="@layout/error_state"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
```
```kotlin
val stub = findViewById<ViewStub>(R.id.stub_error)
stub.inflate()
```
After inflation, the `ViewStub` is replaced by the inflated view. It cannot be re-inflated.
### RecyclerView over ListView
Always use `RecyclerView`. `ListView` creates a new view for every item — no recycling.
`RecyclerView` reuses view holders and provides built-in diffing via `DiffUtil`.
### Compound Drawables
When a `TextView` has an adjacent `ImageView` (icon + text), replace both with a single
`TextView` using compound drawables:
```xml
<TextView
android:drawableStart="@drawable/ic_search"
android:drawablePadding="8dp"
android:text="@string/search" />
```
This eliminates one view from the hierarchy.
### CoordinatorLayout
For coordinating scroll-dependent UI (collapsing toolbar, FAB, snackbar). See
[references/XML_LAYOUTS.md](references/XML_LAYOUTS.md) for full patterns with
`AppBarLayout`, `CollapsingToolbarLayout`, and scroll flags.
Key rule: connect `app:layout_behavior="@string/appbar_scrolling_view_behavior"` on
the scrolling sibling, and `app:layout_scrollFlags` on the AppBar children.
### ViewPager2
RecyclerView-based paging. Use `FragmentStateAdapter` for fragment pages,
`RecyclerView.Adapter` for view pages. Connect with `TabLayoutMediator` for tabs.
For new Compose code, prefer `HorizontalPager` (see Compose Layout Rules).
---
## Compose Layout Rules
### Layout Phases
Compose rendering has three phases: **Composition → Layout → Drawing**. Each phase can be
skipped independently when inputs haven't changed.
- **Composition** runs when state read during composition changes.From kvithayathil/agent-resources, Apache-2.0.
More from kvithayathil/agent-resources
- 0.544score
design-an-interface
mattpocock
Generate multiple radically different interface designs for a module using parallel sub-agents.
SkillAFreshness: AClaude Code +9 - 0.539score
grill-me
mattpocock
Interview the user relentlessly about a plan or design until reaching shared understanding, resolving each branch of the decision tree.
SkillAFreshness: AClaude Code +9 - 0.479score
modern-git-patterns
kvithayathil
Use when working with git commands, planning git workflows, advising on git best practices, or needing version-aware git guidance.
SkillCFreshness: CClaude Code +9 - 0.414score
design-md
kvithayathil
Create, consume, and validate DESIGN.md files — the open format for describing visual identity to coding agents.
SkillDFreshness: DClaude Code +9 - 0.410score
provenance-tracking
kvithayathil
Ensures every remote-installed skill has a references/ folder citing its upstream source and can be checked for updates against that source.
SkillDFreshness: DClaude Code +9 - 0.409score
android-di-koin
kvithayathil
Koin dependency injection setup for Android/KMP - module definitions per layer, ViewModel injection, assembling modules in :app, and koinViewModel() in…
SkillDFreshness: DClaude Code +9 - 0.409score
android-error-handling
kvithayathil
Generic Result wrapper, error types, and extension helpers for Android/KMP - Result<T, E>, DataError, EmptyResult, map, onSuccess, onFailure.
SkillDFreshness: DClaude Code +9 - 0.409score
android-module-structure
kvithayathil
Module layout, dependency rules, and Gradle convention plugins for Android and Kotlin Multiplatform (KMP) projects.
SkillDFreshness: DClaude Code +9 - 0.409score
android-navigation
kvithayathil
Type-safe Compose Navigation for Android/KMP - route objects, feature nav graphs, cross-feature callbacks, and wiring in :app.
SkillDFreshness: DClaude Code +9 - 0.409score
android-presentation-mvi
kvithayathil
MVI presentation layer for Android/KMP - State, Action, Event, ViewModel, Root/Screen composable split, UI models, UiText error mapping, and process death…
SkillDFreshness: DClaude Code +9 - 0.409score
android-data-layer
kvithayathil
Data layer patterns for Android/KMP - data sources, repositories, DTOs, mappers, Room entities, Ktor HttpClient, safe call helpers, token storage, and…
SkillDFreshness: DClaude Code +9 - 0.409score
android-testing
kvithayathil
Testing patterns for Android/KMP - ViewModel unit tests with JUnit5, Turbine, AssertK, UnconfinedTestDispatcher, fake repositories, SavedStateHandle, and…
SkillDFreshness: DClaude Code +9
Signals
- Stars
- 0
- Forks
- 0
- Open issues
- 1
- Last commit (this folder)
- Apr 24, 2026 (6 months ago)
From GitHub (fetched Oct 24, 2026).
Details
- Version
- 1.1.0
- License
- Apache-2.0
- Repository
- github.com/kvithayathil/agent-resources
- First seen
- Oct 24, 2026
- Last checked
- Oct 24, 2026
- Source
- GitHubgithub-graphql
More from kvithayathil
- 0.479score
modern-git-patterns
kvithayathil
Use when working with git commands, planning git workflows, advising on git best practices, or needing version-aware git guidance.
SkillCFreshness: CClaude Code +9 - 0.414score
design-md
kvithayathil
Create, consume, and validate DESIGN.md files — the open format for describing visual identity to coding agents.
SkillDFreshness: DClaude Code +9 - 0.410score
provenance-tracking
kvithayathil
Ensures every remote-installed skill has a references/ folder citing its upstream source and can be checked for updates against that source.
SkillDFreshness: DClaude Code +9 - 0.409score
android-data-layer
kvithayathil
Data layer patterns for Android/KMP - data sources, repositories, DTOs, mappers, Room entities, Ktor HttpClient, safe call helpers, token storage, and…
SkillDFreshness: DClaude Code +9 - 0.409score
android-di-koin
kvithayathil
Koin dependency injection setup for Android/KMP - module definitions per layer, ViewModel injection, assembling modules in :app, and koinViewModel() in…
SkillDFreshness: DClaude Code +9 - 0.409score
android-error-handling
kvithayathil
Generic Result wrapper, error types, and extension helpers for Android/KMP - Result<T, E>, DataError, EmptyResult, map, onSuccess, onFailure.
SkillDFreshness: DClaude Code +9
Cite this page
android-layouts skill. Agent Mart. https://agentmart.dev/skills/kvithayathil-android-layouts (last updated 2026-10-24)