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

조회 수: 5 (최근 30일)
Khalil Ishaq
Khalil Ishaq 2016년 12월 8일
편집: Walter Roberson 2016년 12월 8일
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?

채택된 답변

Walter Roberson
Walter Roberson 2016년 12월 8일
편집: Walter Roberson 2016년 12월 8일
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.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Graphics Object Properties에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by