Adapt matlab app size to windows resoultion and scaling
51 views (last 30 days)
Show older comments
Linus Olofsson
on 26 Nov 2018
Answered: Melinda Toth-Zubairi
on 27 Aug 2019
I am having a probleam creating a matlab app for windows that needs to be able to run propperly for machines using different monitors - more precisely at different resolutions, aspect ratios, and windows scalings.
As I understand 'UI Figures' for apps, they can only be given a size by a set number of pixles, and you have to get e.g. screen size and adapt your app size accordingly by using e.g.
screenSize = get(groot,'ScreenSize');
screenWidth = screenSize(3);
screenHeight = screenSize(4);
left = screenWidth*0.1;
bottom = screenHeight*0.1;
width = screenWidth*0.8;
height = screenHeight*0.8;
drawnow;
app.UIFigure.Position = [left bottom width height];
In the above code snippet 'get(groot,'ScreenSize');' seems to get my actual screen resolution of 3440x1440p (ultra-wide) which does not include my windows scaling of 125% scaling, which results in an effective screen resolution of 2752 x 1152 (according to what is my screen resolution). The result is an app sized to fit my 3440x1440p moitot, which leavs most of the UI Figure outside of my "actual" screen of 2752x1152p.
How can I adapt my UIFigure to fit any monitor, no matter the resolution and scaling?
Thanks!
Linus.
0 Comments
Accepted Answer
Melinda Toth-Zubairi
on 27 Aug 2019
Starting in R2019a, MATLAB App Designer offers Apps with Auto-Reflow from the App Designer Start Page. The 2-panel and 3-panel app types are preconfigured to automatically resize and reflow in response to changes in screen size. You can use Apps with Auto-Reflow if you want to avoid writing complex resize logic.
0 Comments
More Answers (0)
See Also
Categories
Find more on Develop Apps Using App Designer in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!