Scrollbar
Scrollbar 是 ScrollView 的视觉搭档。
最小示例
let bar = Scrollbar::new(ScrollbarOrientation::VerticalRight)
.content_length(200)
.viewport_length(20)
.position(self.offset)
.on_scroll(Message::ScrollTo)
.build();关键 builder 方法
Scrollbar::new(...).content_length(...).viewport_length(...).position(...).symbols(...).thumb_style(...)、.track_style(...).on_scroll(...)
State 对象
如果你要显式维护 position 和 content length,就用 ScrollbarState:
let state = ScrollbarState::new(200)
.with_position(40)
.with_viewport_content_length(20);
let bar = Scrollbar::new(ScrollbarOrientation::VerticalRight)
.state(state)
.build();去哪里看真实用法
- 滚动联动:最直接的联动示例
Last updated on
