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

조회 수: 17 (최근 30일)
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);
end
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;
else
% Change to a 1x2 grid
app.GridLayout.RowHeight = {'1x'};
app.GridLayout.ColumnWidth = {'1x', 299};
app.RightPanel.Layout.Row = 1;
app.RightPanel.Layout.Column = 2;
end
end
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개)

카테고리

Help CenterFile Exchange에서 Develop Apps Using App Designer에 대해 자세히 알아보기

제품


릴리스

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by