In appdesigner, is there any way to control which panels change size under auto-reflow?

92 ビュー (過去 30 日間)
Kevin J. Delaney
Kevin J. Delaney 2019 年 4 月 10 日
コメント済み: Mary Hearn 2020 年 4 月 29 日
Under App Designer, is there any way to select which panel(s) change size under "Auto-Reflow"? In the two-panel template, for example, it seems only the right-hand panel changes size with the UI and that this is not user-selectable.


Melissa Williams
Melissa Williams 2019 年 4 月 25 日
Hi Kevn,
You're right, this is not curently user configurable in the design environment. If you wanted to "override" the generated code algorithm and change the behavior, you could do something like this:
Add a startup function and change the Figure Size change callback to use your own function
% Code that executes after component creation
function startupFcn(app)
app.UIFigure.SizeChangedFcn = createCallbackFcn(app, @myUpdateAppLayout, true);
Then add a function and adjust the grid code. In your example to make the left column grow and the right column fixed, you would reverse the line app.GridLayout.ColumnWidth = {'1x', 299}; where 1x is grow and 299 is the fixed width.
function myUpdateAppLayout(app, event)
currentFigureWidth = app.UIFigure.Position(3);
if(currentFigureWidth <= app.onePanelWidth)
% Change to a 2x1 grid
app.GridLayout.RowHeight = {480, 480};
app.GridLayout.ColumnWidth = {'1x'};
app.RightPanel.Layout.Row = 2;
app.RightPanel.Layout.Column = 1;
% Change to a 1x2 grid
app.GridLayout.RowHeight = {'1x'};
app.GridLayout.ColumnWidth = {'1x', 299};
app.RightPanel.Layout.Row = 1;
app.RightPanel.Layout.Column = 2;
Keep in mind, this will "disconnect" you somewhat from the design view layout, if you change the height of your app or the width of your two columns, you will want to update the numbers in your function.
  1 件のコメント
Mary Hearn
Mary Hearn 2020 年 4 月 29 日
Thank you so much for this question and answer. It worked perfectly! I created an auto-reflow 2-panel canvas, and I need the panels to always resize as 50/50. Thank you for this Q&A platform; it is extremely effective and efficient.


その他の回答 (0 件)




Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by