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

81 次查看(过去 30 天)
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?

回答(2 个)

Kevin Holly
Kevin Holly 2022-7-20
编辑:Kevin Holly 2022-7-20
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 2022-7-20
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 个评论
Pietro Fiondella
Pietro Fiondella 2022-7-25
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 2022-7-25
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.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Develop Apps Using App Designer 的更多信息

产品


版本

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by