필터 지우기
필터 지우기

center text in app designer

조회 수: 17 (최근 30일)
piero
piero 2023년 6월 13일
편집: dpb 2023년 6월 15일
hi, it' possibile to center vertically "HALLO" in field?
  댓글 수: 2
dpb
dpb 2023년 6월 13일
Yeah, just klick on the center icon in the 'Horizontal Alignment" property for the Text section you've got in the attached figure.
Don't know if it was intended or not, but English spelling of the greeting is "Hello" instead of "Hallo" -- but it may be something else entirely... :)
piero
piero 2023년 6월 13일
:P
i want alignement verticaly not horizontaly

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

답변 (2개)

Voss
Voss 2023년 6월 13일
이동: Matt J 2023년 6월 14일
Per the documentation, "Text areas are UI components for entering multiple lines of text." Therefore, it makes sense that they don't have a VerticalAlignment property. However, label components do have a VerticalAlignment property, so maybe use a label instead of a text area.
  댓글 수: 7
dpb
dpb 2023년 6월 15일
Well, as my example shows, you can set the background color so the area shows up white as the textarea,but while the textarea has the "box" property and lacks vertical alignment, the label has vertical alignment choices but no outline box.
I tried laying an axes over it to use the box feature there but wasn't successful in being able to make it work as desired; some very bizarre things happen when try to do it that I don't fully understand with respect to positions and don't have time to delve into as deeply as appears would have to do so to resolve.
I don't know otomh that there is a clean solution to produce the effect you're looking for; probably is, but I'm not GUI kind of guy, so my knowledge of the ins and outs of gui layout is very limited.
Possibly a way to work around the issue would be something like
hUIF=uifigure;
hTA=uitextarea(hUIF,'Position',[200 200 51 100],"Value",["";"";"";"Hello";""]);
where you size the text area to fit a given number (odd) of lines and then space down to show text where it is wanted. This, of course, is extremely fragile and also defeats the purpose of the control.
Again, if you would describe what the GUI is intended to be doing functionally instead of just focusing on a preconceived notion, somebody could probably help redesign the UI to provide that functionality cleanly without all these machinations trying to make something of what isn't.
piero
piero 2023년 6월 15일
thanks

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


dpb
dpb 2023년 6월 15일
편집: dpb 2023년 6월 15일
Well, it CAN be done; don't know that I would recommend it still, but...
hUIF=uifigure;
pLbl=[200 200 50 100]; % label position vector (L, R, W, H) in pixels relative figure
hLbl=uilabel(hUIF,'Position',pLbl,"Text","Hello",'VerticalAlignment','center','BackgroundColor','w');
pAx=pLbl+[0 0 1 1]; % axis position one pixel wider/taller than label...
hAx=axes(hUIF,'Position',pAx,'color','none','Units','pixels'); % actual position is way out in right field somewhere???
hAx.Position=pAx; % Mandatory to place axes in visible location. WHY IS UNKNOWN????
hAx.Box='on'; % draw the outer outlines
yticks(hAx,[]) % don't show ticks/labels
xticks(hAx,[]
creates a label with a box apparently drawn around it.
The "tricks" are:
  1. The initial positioning of the axes is somewhere off in never-never land even though it's directed to be at the same offset from the figure as that of the label. Rewriting/repositioning after it is created seems to fix this. No idea what this is all about...
  2. The axes has to be at least one pixel taller/wider than the label for the top and RH axes lines to be visible. Hence the adjustment of the label coordinates vector when creating the axes. This is the issue couldn't figure out before; dawned on me overnight what the likely issue was/is...

카테고리

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