How can I make my GUI fit with any screen resolution and size?

6 visualizzazioni (ultimi 30 giorni)
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?

Risposta accettata

Walter Roberson
Walter Roberson il 8 Dic 2016
Modificato: Walter Roberson il 8 Dic 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:
  • Character width = width of the letter x.
  • Character height = distance between the baselines of two lines of text.
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.

Più risposte (0)

Categorie

Scopri di più su Graphics Object Properties in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by