The problem, as I see it, is that given a uigridlayout, I can determine its size by examining the Positions of its children and applying the layout's RowSpacing and ColumnSpacing, but I can't determine it's Position (x,y). That means if I have a uigridlayout nested inside another uigridlayout, I cannot even determine the outer layout's size without reproducing (or trying to reproduce) all of the uigridlayout's resizing logic.
Determine size of programmatic layout
2 views (last 30 days)
Show older comments
I am designing a tool to create an app programmatically using uifigure and its various containers. I specifically plan to use uigridlayout in order to take advantage of its automatic sizing using 'fit'. After the figure is laid out, I would like to resize the uifigure to the size of the enclosed layout.
- This would be trivial if the uigridlayout had a 'Position' property.
- I can look at the 'Position' property of all the widgets contained in the uigridlayout to calculate the maximum width and height, but note that those values are only relative to the enclosing layout (the uigridlayout). If I nest a uigridlayout inside another uigridlayout, I have to perform this operation recursively to find the overall dimensions.
- I assume the same holds true for any nested containers
Is there an easier way?
3 Comments
Matthew Reaves
on 26 Dec 2021
I am also interested in this issue. I am working on a UI. I organized uilabel's and uieditfield's into uipanel's, arranging them using a uigridlayout whose parent is the uipanel. I would like that panel to automatically resize to fit the entire contents of the uigridlayout, but it does not appear that this is supported.
Accepted Answer
Pratheek
on 23 Feb 2024
Hi Norton,
The Position property has been added to the uigridlayout in MATLAB R2022b, which simplifies the process of resizing the uifigure to match the size of the enclosed layout.
Please find the documentation link below:
0 Comments
More Answers (0)
See Also
Categories
Find more on Develop uifigure-Based Apps in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!