1---2name: android-viewsystem-foundations3description: Handle XML layouts, ConstraintLayout, Fragments, ViewBinding, DataBinding, and classic Android UI lifecycle patterns.4---5# Android ViewSystem Foundations67## When To Use8- Use this skill when the request is about: xml layout android issue, fragment lifecycle android, constraintlayout cleanup.9- Primary outcome: Handle XML layouts, ConstraintLayout, Fragments, ViewBinding, DataBinding, and classic Android UI lifecycle patterns.10- Reach for this skill when the main surface is XML, Fragment, RecyclerView, or binding lifecycle work rather than Compose-first UI.11- Handoff skills when the scope expands:12- `android-compose-xml-interoperability`13- `android-testing-ui`1415## Workflow161. Identify whether the target surface is Fragment, Activity, custom view, RecyclerView, or a mixed Compose/View interoperability screen.172. Anchor ownership correctly: view bindings to the view lifecycle, adapters to explicit item models, and navigation/transactions outside leaf views.183. Fix layout and rendering issues with classic View tools first: ConstraintLayout, RecyclerView diffing, window insets, and binding-safe updates.194. Exercise Fragment recreation, long text, font scaling, RTL, and process-lifecycle edges before considering the change complete.205. Hand off Compose interoperability or UI test depth only after the View-system ownership model is stable.2122## Guardrails23- Optimize for stable state and predictable rendering before adding animation or abstraction.24- Respect accessibility semantics, contrast, focus order, and touch target guidance by default.25- Do not mix Compose and View system ownership without an explicit interoperability boundary.26- Prefer measured performance work over premature micro-optimizations.27- Clear ViewBinding references when the Fragment view is destroyed; do not keep view references alive past the view lifecycle.2829## Anti-Patterns30- Embedding navigation or business logic directly in leaf UI components.31- Using fixed dimensions that break on localization or dynamic text.32- Ignoring semantics and announcing only visual changes.33- Porting XML patterns directly into Compose without adapting the mental model.34- Holding Fragment view state in stale bindings, view references, or adapters across view recreation.3536## Examples37### Happy path38- Scenario: Refine the XML OrbitTasks screen with ViewBinding and explicit fragment-safe patterns.39- Command: `cd examples/orbittasks-xml && ./gradlew :app:testDebugUnitTest`4041### Edge case42- Scenario: Handle configuration changes, view lifecycle, and long content in classic layouts.43- Command: `cd examples/orbittasks-xml && ./gradlew :app:connectedDebugAndroidTest`4445### Failure recovery46- Scenario: Prevent XML or Fragment requests from being routed to Compose-first skills.47- Command: `python3 scripts/eval_triggers.py --skill android-viewsystem-foundations`4849## Done Checklist50- The implementation path is explicit, minimal, and tied to the right Android surface.51- Relevant example commands and benchmark prompts have been exercised or updated.52- Handoffs to adjacent skills are documented when the request crosses boundaries.53- Official references cover the chosen pattern and the main migration or troubleshooting path.5455## Official References56- [https://developer.android.com/guide/fragments](https://developer.android.com/guide/fragments)57- [https://developer.android.com/topic/libraries/view-binding](https://developer.android.com/topic/libraries/view-binding)58- [https://developer.android.com/training/constraint-layout](https://developer.android.com/training/constraint-layout)59- [https://developer.android.com/topic/libraries/data-binding](https://developer.android.com/topic/libraries/data-binding)