Free Ebook cover Mobile Game Development Essentials: Controls, Performance, and Publishing Readiness

Mobile Game Development Essentials: Controls, Performance, and Publishing Readiness

New course

10 pages

UI Scaling for Mobile Games: Layout Systems and Readability

Capítulo 4

Estimated reading time: 10 minutes

+ Exercise

Build an Adaptive UI Without Engine Lock-In

An adaptive UI is a set of rules that converts a changing screen (size, density, language length, accessibility settings) into stable, readable layouts. To avoid engine lock-in, describe your UI in terms of layout primitives (anchors, margins, stacks, constraints), content rules (text can grow, icons can shrink), and assets that scale (9-slice, SDF, vector where appropriate). The goal is to stop placing pixels and start placing relationships.

Core idea: separate “structure” from “skin”

  • Structure: containers, alignment, spacing, sizing rules, and constraints.
  • Skin: fonts, colors, sprites, icons, and decoration.
  • Content: localized strings, dynamic numbers, player names, and variable lists.

If structure is correct, you can swap skins and content without breaking layout.

1) Layout Primitives

Anchors and alignment (place relative to edges and centers)

Anchors define which part of the parent a UI element is attached to. Use anchors to express intent: “this stays in the top-left,” “this stays centered,” “this stretches horizontally.” Avoid absolute positions except for tiny offsets.

  • Corner anchor: good for HUD counters, back buttons, minimap frames.
  • Center anchor: good for modal dialogs, crosshair overlays.
  • Stretch anchor: good for top bars, bottom nav, full-width panels.

Margins and padding (control breathing room)

Use margins for space outside an element and padding for space inside a container. Keep spacing consistent by defining a spacing scale (e.g., 4/8/12/16/24 units) and using those values everywhere.

TokenExample valueUse
space-14tight icon gaps
space-28default padding
space-312between rows
space-416section separation
space-624modal padding

Stacks and grids (layout by flow, not coordinates)

Stacks (vertical/horizontal) and grids are the most portable way to build UI across engines. They reduce manual placement and handle dynamic content naturally.

Continue in our app.

You can listen to the audiobook with the screen off, receive a free certificate for this course, and also have access to 5,000 other free online courses.

Or continue reading below...
Download App

Download the app

  • Vertical stack: menus, settings lists, quest lists.
  • Horizontal stack: currency row, button bars, tab strips.
  • Grid: inventory, level select, cosmetics gallery.

Prefer content-driven sizing: let children define their preferred size (text width/height, icon size), then the container arranges them with consistent spacing.

Responsive constraints (rules that resolve conflicts)

Constraints describe how elements behave when space changes. A constraint system can be implemented in any engine because it’s just a set of priorities and min/max rules.

  • Min/Max size: e.g., button height min 44px; panel width max 560px.
  • Aspect constraints: keep avatar frames square; keep card art 16:9.
  • Priority rules: “title text may wrap; price must stay visible.”
  • Compression resistance: which elements shrink first (icons) vs last (primary text).

Practical step-by-step: build a responsive shop header

Scenario: a header with (left) back button, (center) title, (right) currency group. The title must remain readable; currency must not overlap; layout must survive long localized titles.

  1. Create a horizontal container anchored to the top and set to stretch width.
  2. Apply padding using your spacing tokens (e.g., 16 left/right, 12 top/bottom).
  3. Add three children: BackButton (fixed), Title (flex), CurrencyGroup (fixed).
  4. Set sizing rules: BackButton min 44x44; CurrencyGroup min width based on its contents; Title takes remaining space.
  5. Set alignment: BackButton left-aligned; CurrencyGroup right-aligned; Title centered within its own flexible region.
  6. Set text behavior: Title allows 2 lines max; if still too long, apply ellipsis at end.
  7. Set priorities: CurrencyGroup visibility priority higher than Title; Title wraps before CurrencyGroup compresses.
// Engine-agnostic pseudo-layout rules HeaderRow: HStack(padding=space-4, align=center, width=stretch) BackButton: size(min=44x44) Title: flex=1, text(maxLines=2, overflow=ellipsis) CurrencyGroup: size(min=content), align=right

2) Typography and Readability

Minimum sizes (design for real viewing distance)

Mobile text that looks fine on a desktop preview can become unreadable in-hand. Establish a minimum readable size for body text and avoid going below it for anything the player must read to make decisions.

  • Body text: aim for a minimum around 14–16 px equivalent at runtime for typical viewing distance.
  • Secondary labels: avoid below 12–13 px unless purely decorative.
  • Critical UI (buttons, prices, timers): prefer 16+ px and strong contrast.

Because engines differ in how they map points to pixels, treat these as visual targets: verify on devices and adjust your scale curve.

Contrast and backgrounds (keep text readable over art)

Text should not rely on the scene behind it. Use one of these patterns:

  • Solid/blurred scrim: a semi-opaque panel behind text.
  • Gradient overlay: dark-to-transparent behind top HUD.
  • Outline/shadow: helpful, but don’t use as the only contrast tool.

Practical rule: if you screenshot the UI and convert it to grayscale, the text should still separate clearly from its background.

Line length and wrapping (reduce scanning effort)

Long lines are harder to read on small screens. For paragraphs, constrain the text container width so lines don’t become too long on tablets. For narrow phones, allow wrapping and increase line height slightly.

  • Preferred line length: roughly 35–60 characters per line for body text.
  • Line height: increase for small fonts and dense UI (e.g., 1.2–1.4x).

Dynamic text (numbers, player names, localization)

UI text is rarely static: currencies grow, timers change, names vary, and translations expand. Design for expansion rather than trimming after the fact.

  • Reserve space for growth: e.g., currency “9,999,999” not “999”.
  • Use tabular numerals for counters/timers to prevent jitter when digits change.
  • Allow wrapping for descriptions; avoid wrapping for short labels by giving them flexible width.
  • Fallback fonts: ensure glyph coverage for target languages.

Practical step-by-step: make a button label resilient

  1. Set a minimum button height (see touch targets below) and generous horizontal padding.
  2. Choose a label style with a minimum readable size (e.g., 16 px equivalent).
  3. Enable auto-fit only as a last resort: allow 1 line; if overflow, try 2 lines; if still overflow, then reduce font size within a small range (e.g., down to 14).
  4. Set overflow behavior: prefer wrapping for action phrases (“Collect Reward”) and ellipsis for long single tokens (usernames).

3) Touch Targets

Recommended hit box sizing (separate visuals from interaction)

Touch targets should be sized for fingers, not for icons. A common baseline is 44–48 px minimum hit area (or the platform’s recommended minimum). The visible icon can be smaller, but the hit box should meet the minimum.

  • Minimum hit size: 44–48 px square equivalent.
  • Primary actions: consider 48–56 px height for comfortable tapping.
  • Small icons: keep icon at 20–28 px but wrap in a larger invisible button.

Spacing between targets (prevent mis-taps)

When two targets are close, the effective error rate rises sharply. Use consistent gaps and avoid placing destructive actions next to frequent actions.

  • Minimum gap: aim for 8–12 px between hit boxes.
  • Destructive actions: add extra separation or require confirmation.

Edge avoidance (thumb comfort and accidental touches)

Interactive elements placed too close to screen edges are easier to miss and more likely to conflict with system gestures. Keep a comfortable inset for tappable UI and increase it for frequently used controls.

  • Inset interactive UI: keep buttons away from edges by a consistent margin.
  • Bottom corners: be cautious with swipe areas; ensure the hit box doesn’t hug the edge.

Practical step-by-step: upgrade a tiny close “X”

  1. Keep the icon at a visually appropriate size (e.g., 20–24 px).
  2. Create a button hit box of at least 44–48 px.
  3. Center the icon inside the hit box.
  4. Add padding around the hit box so it doesn’t collide with nearby targets.
  5. Test with one hand: ensure it’s easy to hit repeatedly without mis-taps.

4) Scalable Art Approaches

Vector vs raster (choose per asset type)

Vector art scales cleanly and is ideal for simple icons, shapes, and UI chrome. Raster (bitmaps) is better for detailed illustrations, textured panels, and painterly art. In practice, many engines rasterize vectors at runtime or import time, so the key is to keep a high-quality source and export appropriate sizes.

  • Use vector-like sources for icons/logos (SVG/AI), then export to multiple raster sizes if needed.
  • Use raster for complex art, but plan for multiple density variants.

9-slice / 9-patch (scale panels without distortion)

9-slice divides an image into corners, edges, and a center. Corners stay fixed, edges stretch in one direction, center stretches freely. This is the standard solution for scalable buttons, panels, tooltips, and dialog backgrounds.

Practical step-by-step: create a scalable panel

  1. Design the panel with clear corner shapes and a flat/tiling center.
  2. Define slice guides so corners include all rounded edges and borders.
  3. Set border thickness to remain constant across sizes (don’t let it blur).
  4. Test extreme sizes: very small (minimum) and very large (tablet) to ensure corners don’t overlap and edges don’t look stretched.

Signed Distance Fields (SDF) conceptually (sharp edges across scales)

SDF is a technique where you store, for each pixel, the distance to the nearest edge of a shape. At render time, the engine reconstructs crisp edges at different scales by thresholding that distance. Conceptually, it’s a way to make text and icons scale with less blurring than standard bitmaps.

  • Best for: fonts, monochrome icons, simple shapes.
  • Watch for: very thin details can break; extreme scaling can reveal artifacts if the SDF resolution is too low.
  • Styling: outlines and glows can be generated consistently from the distance field.

Practical step-by-step: pick an art scaling strategy per UI layer

  1. Text: prefer font rendering or SDF fonts for consistent sharpness.
  2. Icons: use vector sources; render as SDF or export multiple raster sizes.
  3. Panels/buttons: use 9-slice for borders and backgrounds.
  4. Illustrations: export raster variants per DPI class; avoid scaling a single low-res image up.

5) UI Validation Checklist

Device and DPI class coverage

  • Verify UI on multiple density classes (low/medium/high) to catch blurry rasters and overly thin strokes.
  • Check that minimum hit sizes remain valid after scaling rules apply.
  • Confirm that icons and text remain aligned on fractional scaling (e.g., 1.25x) without jitter.

Language and localization stress tests

  • Long-text languages: test with artificially expanded strings (e.g., +30–50%) to reveal clipping.
  • Non-Latin scripts: verify glyph coverage and baseline alignment.
  • Right-to-left (RTL): ensure stacks/grids can mirror and that icons with directionality (arrows) swap appropriately.
  • Pluralization and number formatting: verify that dynamic strings don’t overflow when separators change (e.g., 1,000 vs 1.000).

Accessibility text scaling (oversized text)

  • Test with large system text / in-game text scaling at maximum.
  • Ensure layouts reflow: labels wrap, stacks grow vertically, scroll views appear when needed.
  • Confirm that critical actions remain visible without overlapping (e.g., “Confirm” not pushed off-screen).

Readability checks

  • Text over backgrounds: verify contrast with real gameplay scenes behind HUD.
  • Check line length on tablets: ensure paragraphs don’t become too wide; constrain content width.
  • Verify numeric stability: counters/timers don’t shift position when digits change (tabular numerals or fixed-width containers).

Touch and interaction checks

  • All tappable elements meet minimum hit size; small icons have expanded invisible hit areas.
  • Spacing between adjacent targets prevents mis-taps, especially in dense toolbars.
  • Destructive actions are separated and/or confirmed.
  • Interactive elements are not placed uncomfortably close to edges; frequent actions are easy to reach.

Layout robustness checks

  • Modal dialogs: content scrolls if it exceeds available height; buttons remain reachable.
  • Lists/grids: empty states and very long lists behave correctly (no overlap, consistent spacing).
  • Aspect-dependent components (cards, avatars) maintain intended proportions.
  • 9-slice assets: borders remain crisp at min/max sizes; corners never stretch.

Now answer the exercise about the content:

When building a responsive shop header with a back button (left), title (center), and currency group (right), which priority rule best prevents overlap while keeping key information visible on small screens or with long localized titles?

You are right! Congratulations, now go to the next page

You missed! Try again.

Priority rules should keep critical elements visible. The currency group is set to stay visible while the title flexes: it wraps up to a limit and then uses ellipsis, preventing overlap on small screens or long text.

Next chapter

Performance and Battery Essentials for Mobile Game Development

Arrow Right Icon
Download the app to earn free Certification and listen to the courses in the background, even with the screen off.