GUI Resizing Issue for Different Screen Resolutions

6 次查看(过去 30 天)
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