This document is in beta. Help us by reporting issues via Github or email
On this page:
Make sure users can access all information and functionality on a screen that’s as wide as on the iPhone5, without needing to scroll in both directions.
On smaller devices or when content is zoomed there should be no loss of information or functionality, and users should not be required to scroll content both vertically and horizontally.
1.4.10 Reflow (Level AA): Content can be presented without loss of information or functionality, and without requiring scrolling in two dimensions for:
- Vertical scrolling content at a width equivalent to 320 CSS pixels;
- Horizontal scrolling content at a height equivalent to 256 CSS pixels.
Except for parts of the content which require two-dimensional layout for usage or meaning.
Note: 320 CSS pixels is equivalent to a starting viewport width of 1280 CSS pixels wide at 400% zoom. For web content which is designed to scroll horizontally (e.g., with vertical text), 256 CSS pixels is equivalent to a starting viewport height of 1024 CSS pixels at 400% zoom.
Examples of content which requires two-dimensional layout are images, maps, diagrams, video, games, presentations, data tables, and interfaces where it is necessary to keep toolbars in view while manipulating content.
See the W3C’s detailed explanation of this guideline with techniques and examples.
This section needs more content. Contribute via Github or email.
// Allowing a label to wrap onto multiple lines
label.numberOfLines = 0
// Reacting to changes in the trait collection, like contentSizeCategory and sizeClass
override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {
super.traitCollectionDidChange(previousTraitCollection)
if traitCollection.horizontalSizeClass == .compact {
stackView.axis = .vertical
} else {
stackView.axis = .horiztonal
}
if traitCollection.preferredContentSizeCategory >= .accessibilityLarge {
stackView.axis = .vertical
} else {
stackView.axis = .horiztonal
}
}
NOTE: You could also observe traitCollectionDidChange to modify UICollectionView layouts to reflow your layout.
All Views will automatically allocate its content, as long as there’s no height
restriction. Using android:layout_height="wrap_content"
is strongly recommended whenever possible.
If you’re using a ConstraintLayout
, make sure it has match_parent
on both height and width to fill the whole viewport. Make sure all its child Views are properly constrained to the edges.
In case of a screen with a huge load of content, it’s recommended to add a ScrollView
to allow the users to scroll vertically when the screen is zoomed.
Flutter will by default shrink and grow its widgets to meet the content height restriction as long as the container of the text/content does not have a set height.
If a widget goes off screen on a device it will show a overflow error on the screen during development.
Text in Text()
widgets will naturally be softwrapped but can have this functionality toggled.
softWrap: bool, // defaults to true
Make sure that your screen/widget is scrollable you can use widgets like SingleChildScrollView()
to wrap your ui to make it scrollable. Widgets like ListView.builder
are scrollable by default.
SingleChildScrollView(
child: // the rest of your ui here
)
Scrolling direction is locked to a default direction but can have this toggled.
scrollDirection: Axis.enum, // defaults to Axis.vertical
See the W3C’s detailed explanation of this guideline with techniques and examples.
This section needs more content. Contribute via Github or email.
The use of <code><pre> formatted content (such as code) can cause horizontal scrolling. Using the CSS declarations such as word-wrap: break-word; on <code><pre> in small viewports will help to avoid horizontal scrolling at all.
This document is in beta. Help us by reporting issues via Github or email