MATLAB Answers

How do I make an App window full screen programmatically in MATLAB?

192 views (last 30 days)
Adrian Quesada
Adrian Quesada on 17 Aug 2018
I have a Matlab app, and I would like that it starts always maximized without using the mouse to maximize the figure window.
Image Analyst
Image Analyst on 4 Dec 2018
I called tech support today, because it seemed to maximize if I set a break point there, and not maximize if there was no breakpoint there. They never did figure that out, but we did figure out that you need to call drawnow before you set the WindowState to 'maximized'. If you do that, it does move the controls to full screen, though their position is goofy. It's not just a magnified version of the smaller figure you had designed. The controls stay the same size (don't enlarge) and it has some nonsensical (to me anyway) rules for positioning the controls to their new locations on the full screen.

Sign in to comment.

Answers (2)

Marek Svoboda
Marek Svoboda on 18 Aug 2019
Edited: Marek Svoboda on 18 Aug 2019
OK, so the information is all here but needs to be peaced together. I suggest a new complete answer, which is:
Left click "app.UIFigure" in the Component Browser (right column) -> "Callbacks" -> "Add startupFcn callback" -> enter the following code:
function startupFcn(app)
app.UIFigure.WindowState = 'maximized';
This opens the window in smaller size on startup and subsequently resizes it, adjusting the content appropriately. For the resizing of the contents to really work properly, I higly recommend using an "Auto-Reflow" (i.e. responsive) layout of your app. If you leave out drawnow, the app opens fullscreen right away, but it does not adjust the contents.
Shreedhar Savant Todkar
Shreedhar Savant Todkar on 26 Jan 2021
@Krutik Gujarathi just add the following line in the OutputFcn:
IMPORTANT: All the objects will need resizing and they mess up the layout when used on different windows. So I'd suggest to do the following:
  1. Double click on the object (Pushbutton, Radiobutton etc.)
  2. Change the "Units" to "normalized"
  3. Repeat for every object in your UIfigure

Sign in to comment.




Community Treasure Hunt

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

Start Hunting!