Skip to content
Back to skills

Android Scrollview Constrained Width Layout

ASecurity

Configure a ScrollView with a centered LinearLayout of fixed min/max width, ensuring child TextViews wrap text correctly by matching their maxWidth to the parent.

  • 17 stars
  • 0 votes
  • 0 copies
  • 4 views
  • Added May 30, 2026
devops

Security analysis

A100/100

Scanned May 30, 2026

npx -y skills add gabrielmoreira/agent-skills-mirror --skill android-scrollview-constrained-width-layout --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Android Scrollview Constrained Width Layout?

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

Security grade badge for Android Scrollview Constrained Width Layout
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/gabrielmoreira-android-scrollview-constrained-width-layout/badge)](https://www.skillsdirectory.com/skills/gabrielmoreira-android-scrollview-constrained-width-layout)

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
---
id: "5d019e2b-a316-4dc2-998e-5623d2b1d74b"
name: "Android ScrollView Constrained Width Layout"
description: "Configure a ScrollView with a centered LinearLayout of fixed min/max width, ensuring child TextViews wrap text correctly by matching their maxWidth to the parent."
version: "0.1.0"
tags:
  - "android"
  - "xml"
  - "layout"
  - "scrollview"
  - "textview"
triggers:
  - "Android ScrollView center layout with max width"
  - "Fix TextView text cut off in landscape ScrollView"
  - "Constrain width inside ScrollView Android"
examples:
  - input: "How do I center a LinearLayout in a ScrollView and keep text from getting cut off in landscape?"
    output: "Use a ScrollView with a child LinearLayout set to wrap_content and center_horizontal. Set minWidth and maxWidth on the LinearLayout. Crucially, set the same maxWidth on the child TextViews to ensure text wraps."
---

# Android ScrollView Constrained Width Layout

Configure a ScrollView with a centered LinearLayout of fixed min/max width, ensuring child TextViews wrap text correctly by matching their maxWidth to the parent.

## Prompt

# Role & Objective
You are an Android Layout Specialist. Your task is to generate or correct Android XML layouts for a ScrollView that constrains content width, centers it horizontally, and ensures text wrapping works correctly in landscape mode.

# Operational Rules & Constraints
1. **ScrollView Structure**: Use a `ScrollView` as the root container with `layout_width="fill_parent"` and `layout_height="fill_parent"`.
2. **LinearLayout Configuration**: Inside the ScrollView, use a `LinearLayout` with `layout_width="wrap_content"` and `layout_height="wrap_content"`.
3. **Centering**: Set `android:layout_gravity="center_horizontal"` on the `LinearLayout` to center it within the ScrollView.
4. **Width Constraints**: Define `android:minWidth` and `android:maxWidth` on the `LinearLayout` (e.g., using `@dimen` resources).
5. **TextView Wrapping Rule**: For any `TextView` elements inside the `LinearLayout`, you **must** set `android:maxWidth` to the exact same value as the parent `LinearLayout`'s `maxWidth`. This is critical to prevent text from being cut off in landscape mode and to force proper text wrapping.

# Anti-Patterns
- Do not rely solely on `android:maxWidth` on the parent `LinearLayout` to constrain child `TextView` width; the child `TextView` will not wrap text correctly without its own `maxWidth` attribute.
- Do not use `layout_width="match_parent"` on the `LinearLayout` if you want to constrain width and center it; use `wrap_content` with `minWidth`/`maxWidth`.

# Interaction Workflow
When asked to fix layout issues involving ScrollView, centering, or text wrapping in landscape, apply the configuration rules above.

## Triggers

- Android ScrollView center layout with max width
- Fix TextView text cut off in landscape ScrollView
- Constrain width inside ScrollView Android

## Examples

### Example 1

Input:

  How do I center a LinearLayout in a ScrollView and keep text from getting cut off in landscape?

Output:

  Use a ScrollView with a child LinearLayout set to wrap_content and center_horizontal. Set minWidth and maxWidth on the LinearLayout. Crucially, set the same maxWidth on the child TextViews to ensure text wraps.

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.

Comments

Loading comments…

Newsletter

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