GUI Resizing Issue for Different Screen Resolutions

조회 수: 8 (최근 30일)
SWAROOP HP
SWAROOP HP 2019년 2월 5일
댓글: Luna 2019년 2월 12일
I have created a programmatic GUI in Matlab R2016a. The GUI was created on desktop with screen resolution 1920x1200. Although I have chosen units as 'normalized' for all the components created, the components are not getting resized proprtionallly when used with different screen resolutions. Is it really necessary to write a SizeChangedFcn to accomodate different screen resolution or is there any easy way forward?

답변 (1개)

Luna
Luna 2019년 2월 5일
The best, easiest and effortless way to do it is using GUI Layout Toolbox from FEX.
You will never need to implement SizeChangedFcn to all your components.
Put your ui elements inside the containers which are created by uix or uiextrax class as children.
Example:
figHandle = figure;
ButtonBox = uix.HButtonBox('Parent',figHandle,'ButtonSize',[100 50]); % Creates Horizontal Button Box, each button you created below put horizontally
buttonHandle1 = uicontrol('Parent',ButtonBox,'Style','pushbutton','String','OK');
buttonHandle2 = uicontrol('Parent',ButtonBox,'Style','pushbutton','String','Cancel');
There are other options for both vertical and horizontally as boxes, panels, etc..
You can read the documentation.
  댓글 수: 7
Adam
Adam 2019년 2월 12일
Place it inside either a uix.HBox or uix.VBox layout that is parented by the panel. Then it will automatrically resize with the panel. You can use uix.Empty to provide padding if you want or multiple HBox or VBox layouts to put other components in too if you need.
If you make a panel that is just for the table though then the table can fill that whole panel within a layout.
Luna
Luna 2019년 2월 12일
Just addition what Adam said, you can also use HBox's Width property and VBox's Heights property to resize what number of elements you put in that Box.
For example if you have 3 items in your VBox:
myItemsVBox.Heights = [-1, -3, -3]; % that makes 1st element 3x times narrower than the last two.
% same for HBox.
% Just be sure that you create the vector same size of the element number.
Also you can use VBoxFlex and HBoxFlex that allows you to resize with mouse.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Migrate GUIDE Apps에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by