Skip to content
Back to skills

Android Xml Views

ASecurity

For a complex screen, replace the nested `LinearLayout` tree with one flat `ConstraintLayout`. Position views using constraints, chains, guidelines, or barriers instead of adding wrapper containers. A `0dp` dimension means “match the available space defined by the constraints.” For example, a title, subtitle, and action can be laid out without nested rows or columns: ```xml <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app=...

  • 584 stars
  • 0 votes
  • 0 copies
  • 5 views
  • Added September 5, 2026
development

Security analysis

A100/100

Pro scans all 18 files and shows the line behind each finding

Scanned September 5, 2026

npx -y skills add HoangNguyen0403/agent-skills-standard --skill android-xml-views --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Android Xml Views?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Android Xml Views
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/hoangnguyen0403-android-xml-views-6ff9c57c/badge)](https://www.skillsdirectory.com/skills/hoangnguyen0403-android-xml-views-6ff9c57c)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
# Flatten the XML with `ConstraintLayout`

For a complex screen, replace the nested `LinearLayout` tree with one flat `ConstraintLayout`. Position views using constraints, chains, guidelines, or barriers instead of adding wrapper containers. A `0dp` dimension means “match the available space defined by the constraints.”

For example, a title, subtitle, and action can be laid out without nested rows or columns:

```xml
<androidx.constraintlayout.widget.ConstraintLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:padding="16dp">

    <TextView
        android:id="@+id/title"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:text="Title"
        android:textAppearance="@style/TextAppearance.AppCompat.Title"
        app:layout_constraintEnd_toStartOf="@id/action"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

    <TextView
        android:id="@+id/subtitle"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_marginTop="4dp"
        android:text="Supporting text"
        app:layout_constraintEnd_toStartOf="@id/action"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@id/title" />

    <Button
        android:id="@+id/action"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Open"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

</androidx.constraintlayout.widget.ConstraintLayout>
```

The exact constraints should reflect the design: use a vertical chain for evenly distributed content, a guideline for a shared alignment edge, and a barrier when one view's dynamic height or width must determine another view's position. Keep a single `LinearLayout` for a genuinely simple one-dimensional group if it is clearer, but avoid repeatedly nesting `LinearLayout` inside `LinearLayout`; deep hierarchies increase measure/layout work and make maintenance harder. Ensure the module includes the AndroidX ConstraintLayout dependency.

Files in this skill

  • eval-1.baseline.md1.7 KB
  • eval-1.with-skill.md1.4 KB
  • eval-2.baseline.md2 KB
  • eval-2.with-skill.md2 KB
  • eval-3.baseline.md2.3 KB
  • eval-3.with-skill.md2.3 KB
  • trigger-1.md124 B
  • trigger-10.md137 B
  • trigger-11.md129 B
  • trigger-2.md120 B
  • trigger-3.md122 B
  • trigger-4.md129 B
  • trigger-5.md107 B
  • trigger-6.md115 B
  • trigger-7.md149 B
  • trigger-8.md152 B
  • trigger-9.md134 B

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in development →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.