This page was machine-translated from Portuguese and may contain errors. The Portuguese version is canonical.
Accessibility (a11y)
With honesty about what the framework offers today: focus on what is actionable in native/OpenGL CrossFly. Much of a11y here reinforces responsiveness — font-relative sizing is respect for the user’s size setting.
Generous touch targets
Size tappable areas with Relative, never tiny pixels:
botao.getStyle().autoHeight(Relative.ofFont(2.5f)); // tall enough for the finger
icone.getStyle().autoWidth(Relative.ofScreen(0.12f, ScreenSize.MIN))
.autoHeight(Relative.ofScreen(0.12f, ScreenSize.MIN)); // square that adapts
Rule of thumb: targets of ~48 dp equivalents — Relative.ofFont(2.5f) usually does the job.
Text contrast
Ensure adequate contrast; the framework helps:
int fundo = cs.surface.color();
int texto = ColorUtils.contrastText(fundo); // black/white depending on the background
int melhor = ColorUtils.getContrastColor(fundo, 0xFF000000, 0xFFFFFFFF); // picks between 2 options
Respect the light/dark theme (via Styles.setColorScheme/setDarkMode) — don’t hardcode colors that
ignore the mode (see Light/dark mode).
Text that scales
Because fonts are measured in relative units, text and layout scale with the app’s font zoom — a
direct consequence of using Relative.ofFont(...) and avoiding fixed pixels. Let the Label wrap;
do not truncate essential information.
Multisensory feedback and voice
Device.vibrate(50); // tactile confirmation of an important action
Device.beep(); // audible alert
Device.textToVoice(mensagem); // voice reading (assistive)
Use it as support, not as the only channel — combine visual + tactile/audio.
Best practices
- Touch targets with
Relative.ofFont/ofScreen(MIN); no few-pixel buttons. - Contrast via
contrastText/getContrastColor; honor light/dark. - Don’t truncate essential text; let it scale/wrap.
Common mistakes
- Tiny buttons/icons in fixed pixels (hard to tap; don’t scale).
- Fixed colors that break contrast in dark mode.
- Relying on color alone to convey state (add an icon/text).
Limitations
Screen reader features depend on the platform/launcher — there is no universal semantic a11y layer in the core. Prioritize the actionable items above.
See also
- Responsiveness · Light/dark mode · Colors (Ch. 11)