Azzera filtri
Azzera filtri

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

17 visualizzazioni (ultimi 30 giorni)
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.

Risposta accettata

Melissa Williams
Melissa Williams il 25 Apr 2019
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 Commento
Mary Hearn
Mary Hearn il 29 Apr 2020
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.

Accedi per commentare.

Più risposte (0)


Scopri di più su Startup and Shutdown in Help Center e File Exchange




Community Treasure Hunt

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

Start Hunting!

Translated by