Closed cdxjcl closed 6 months ago
Hi, and thanks for the report!
To override the size of another view, you actually need to wrap 3 methods:
layout
method, as you did.required_size
method, which helps the parent view properly center the wrapped view.draw
method, which crops the printer given to the wrapped view, preventing it from drawing outside of the new size.The ResizedView
wraps all these, and gives you convenient ways to configure what new size the view should have. For example:
ResizeView::with_fixed_size((4, 1), Layout::new(text))
(Other methods exist to only affect the width or height, and to specify min/max values rather than fixed ones.)
With the convenience Resizable
trait, you can use chainable methods:
Layout::new(text).fixed_size((4, 1))
Thank you for your reply. I used ResizedView and it solved my problem.
Describe the bug I want to limit the size of subviews by wrapping layout method but the result has longer width.
To Reproduce
Expected behavior TextView should only display "ABCD".
Screenshots
Expect:
Environment