different align for each widget at a Colum #1261
Answered
by
hecrj
LuckyTurtleDev
asked this question in
Q&A
-
Beta Was this translation helpful? Give feedback.
Answered by
hecrj
Feb 23, 2022
Replies: 1 comment 3 replies
-
|
You cannot use Instead, you can achieve different alignment by wrapping the items of the use iced::alignment;
use iced::{Column, Container, Element, Length, Sandbox, Settings, Text};
pub fn main() -> iced::Result {
Example::run(Settings::default())
}
#[derive(Default)]
struct Example;
impl Sandbox for Example {
type Message = ();
fn new() -> Self {
Self::default()
}
fn title(&self) -> String {
String::from("Alignment - Iced")
}
fn update(&mut self, _message: ()) {}
fn view(&mut self) -> Element<()> {
Column::new()
.padding(20)
.width(Length::Fill)
.push(Text::new("Left aligned"))
.push(
Container::new(Text::new("Centered!"))
.width(Length::Fill)
.align_x(alignment::Horizontal::Center),
)
.push(
Container::new(Text::new("Right aligned"))
.width(Length::Fill)
.align_x(alignment::Horizontal::Right),
)
.into()
}
} |
Beta Was this translation helpful? Give feedback.
3 replies
Answer selected by
hecrj
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment



You cannot use
align_itemslike that. In general, widgets are declarative and the order in which properties are set does not alter the resulting widget tree.Instead, you can achieve different alignment by wrapping the items of the
Columnin aContainer. For instance: