pub enum CrossAxisAlignment {
Start,
End,
Center,
Stretch,
Baseline,
}Expand description
How the children should be placed along the cross axis in a flex layout.
See also:
RenderFlex, the flex render object.
Variants§
Start
Place the children with their start edge aligned with the start side of the cross axis.
For example, in a column (a flex with a vertical axis) whose TextDirection is
TextDirection::Ltr, this aligns the left edge of the children along the left edge of
the column.
If this value is used in a horizontal direction, a TextDirection must be available to
determine if the start is the left or the right.
If this value is used in a vertical direction, a VerticalDirection must be available
to determine if the start is the top or the bottom.
End
Place the children as close to the end of the cross axis as possible.
For example, in a column (a flex with a vertical axis) whose TextDirection is
TextDirection::Ltr, this aligns the right edge of the children along the right edge
of the column.
If this value is used in a horizontal direction, a TextDirection must be available to
determine if the end is the left or the right.
If this value is used in a vertical direction, a VerticalDirection must be available
to determine if the end is the top or the bottom.
Center
Place the children so that their centers align with the middle of the cross axis.
This is the default cross-axis alignment.
Stretch
Require the children to fill the cross axis.
This causes the constraints passed to the children to be tight in the cross axis.
Baseline
Place the children along the cross axis such that their baselines match.
Consider using this value for any horizontal main axis (as with a row) where the children
primarily contain text. If the different children have text with different font metrics
(for example because they differ in font size or other text style properties, or because
they use different fonts due to being written in different scripts), then this typically
produces better visual alignment than the other CrossAxisAlignment values, which use
no information about where the text sits vertically within its bounding box.
The baseline of a widget is typically the typographic baseline of the first text in the first text widget it encloses, if any. The typographic baseline is a horizontal line used for aligning text, which is specified by each font; for alphabetic scripts, it ordinarily runs along the bottom of letters excluding any descenders.
Because baselines are always horizontal, this alignment is intended for horizontal main
axes (as with a row). If the main axis is vertical (as with a column), then this value is
treated like Start.
For horizontal main axes, if the minimum height constraint passed to the flex layout exceeds the intrinsic height of the cross axis, children will be aligned as close to the top as they can be while honoring the baseline alignment. In other words, the extra space will be below all the children.
Children who report no baseline will be top-aligned.
See also:
AnyRenderBox::get_distance_to_baseline, which defines the baseline of a box.
Trait Implementations§
Source§impl Clone for CrossAxisAlignment
impl Clone for CrossAxisAlignment
impl Copy for CrossAxisAlignment
Source§impl Debug for CrossAxisAlignment
impl Debug for CrossAxisAlignment
impl Eq for CrossAxisAlignment
Source§impl PartialEq for CrossAxisAlignment
impl PartialEq for CrossAxisAlignment
impl StructuralPartialEq for CrossAxisAlignment
Auto Trait Implementations§
impl Freeze for CrossAxisAlignment
impl RefUnwindSafe for CrossAxisAlignment
impl Send for CrossAxisAlignment
impl Sync for CrossAxisAlignment
impl Unpin for CrossAxisAlignment
impl UnsafeUnpin for CrossAxisAlignment
impl UnwindSafe for CrossAxisAlignment
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.