GUI Resizing Issue for Different Screen Resolutions

9 views (last 30 days)
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?

Answers (1)

Luna
Luna on 5 Feb 2019
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 Comments
Adam
Adam on 12 Feb 2019
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 on 12 Feb 2019
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.

Sign in to comment.

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!