- Character width = width of the letter x.
- Character height = distance between the baselines of two lines of text.
How can I make my GUI fit with any screen resolution and size?
9 views (last 30 days)
Show older comments
Khalil Ishaq
on 8 Dec 2016
Edited: Walter Roberson
on 8 Dec 2016
I am using 'character' as a unit for all the objects in my gui. I opened it once in another computer and it was messy. Is there any way I can make it fit on any screen?
0 Comments
Accepted Answer
Walter Roberson
on 8 Dec 2016
Edited: Walter Roberson
on 8 Dec 2016
You can design everything using normalized coordinates instead of characters. As you move to other systems, the size of objects (including text) will shrink or expand. You might still have difficulty if the new system has a different aspect ratio for displays.
You can continue to design using characters, but in the CreateFcn of your figure, you can adjust the root default font property: https://www.mathworks.com/help/matlab/ref/figure-properties.html#property_Units
"These units are based on the default uicontrol font of the graphics root object:
To access the default uicontrol font, use get(groot,'defaultuicontrolFontName') or set(groot,'defaultuicontrolFontName')."
I notice, though, that this refers only to font name and not to font size. That leads open the question of what it is actually referring to. I would recommend also experimenting with setting the defaultuicontrolFontSize .
I notice too that this Figure Properties talks about defaultuicontrolFontName instead of defaultfigureFontName. I wonder if that is an error in the documentation? I think I'll open a support case about this.
Anyhow, what I am getting at here is that what you can do in your figure CreateFcn callback is look at the available size of the screen and from there work out what size of font you need to use so that your figure that was calibrated in 'character' units will still fit on the screen; you would then set the default font name (or default font size) as appropriate so that 'character' positioning will work out.
0 Comments
More Answers (0)
See Also
Categories
Find more on Migrate GUIDE Apps 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!