Android Xml Views
ASecurityFor 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
Security analysis
100/100Pro scans all 18 files and shows the line behind each finding
npx -y skills add HoangNguyen0403/agent-skills-standard --skill android-xml-views --agent claude-codeAre you the author of Android Xml Views?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/hoangnguyen0403-android-xml-views-6ff9c57c)# 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.md
- eval-1.with-skill.md
- eval-2.baseline.md
- eval-2.with-skill.md
- eval-3.baseline.md
- eval-3.with-skill.md
- trigger-1.md
- trigger-10.md
- trigger-11.md
- trigger-2.md
- trigger-3.md
- trigger-4.md
- trigger-5.md
- trigger-6.md
- trigger-7.md
- trigger-8.md
- trigger-9.md
Attribution
Related skills
View all in development →Comments
Loading comments…
Newsletter
Get the weekly list of safe new skills, and the ones we pulled.