How may i fit the app developed in app designer in my window?

67 views (last 30 days)
I created an app on a different computer with a greater screen , now i am tring to run it on my PC but once open it never resize properly.
What is the problem?

Answers (2)

Kevin Holly
Kevin Holly on 20 Jul 2022
Edited: Kevin Holly on 20 Jul 2022
If you want the canvas to take up the whole screen, you can edit the WindowState of the UIFigure in AppDesigner with the Component Browser found on the right panel as shown below.
Another approach, is to use a startup function. On the Editor tab in code view, select Callback. Select the app and then select StartFcn for Callback.
In the startup function, you can convert the units of the uifigure to normalized units and the adjust the position then convert back to pixels units.
function startupFcn(app)
app.UIFigure.Units = "normalized";
app.UIFigure.Position(1) = 0.3;
app.UIFigure.Position(2) = 0.3;
app.UIFigure.Units = "pixels";
end
If you want to take into consideration the different resolution ratio bewteen the x and y axes, you can get the entire screensize as shown below and make adjustments to maintain a particular rectangular shape.
function startupFcn(app)
screen = get(0,'screensize');
xres = screen(3)-screen(1);
yres = screen(4)-screen(2);
app.UIFigure.Units = 'normalized';
app.UIFigure.Position = [0.06, 0.60, 0.3*(yres/xres),0.3];
app.UIFigure.Units = "pixels";
end

Image Analyst
Image Analyst on 20 Jul 2022
On App Designer's IDE right click the top level figure name in the Component Browser panel and add a startup function.
Then at the bottom of the startupFcn function add this line of code:
app.UIFigure.WindowState = "maximized";
The app should resize to maximize on whatever screen of yours it decided to first appear on, on your current lower resolution computer.
  3 Comments
Pietro Fiondella
Pietro Fiondella on 25 Jul 2022
the maximise function only set the UIfiugre full screen, in this way the image still appears as in the attahed figure, i would like to set it centered when the app is in full size
Image Analyst
Image Analyst on 25 Jul 2022
What element? When your app's main figure window is full size, what other "element" do you want to be "centered"?
I'm attaching a CenterFigure function that you may want to try.

Sign in to comment.

Categories

Find more on Develop Apps Using App Designer in Help Center and File Exchange

Products


Release

R2021b

Community Treasure Hunt

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

Start Hunting!