How to give vertical alignment to Text Area component of App designer?

26 次查看(过去 30 天)
Hi,
I want to add text box in my UI. But I want that Text alignment to be vertically and horizontally in center. Currently, it only has horizontal alignment option
Please tell me some solution for this.
  4 个评论
Rik
Rik 2022-2-2
For normal figures this is already a problem. The common solution is to use a text object centered in an axes object. For non-editable fields something like that should be possible in AppDesigner/uifigures as well. For editable text fields I can't think of anything practical.
SRUSHTI KHATAU
SRUSHTI KHATAU 2022-2-2
Okay. Thank you for replying. I will try this option. But, the problem is I have to use large number of Text Area.

请先登录,再进行评论。

回答(1 个)

Nivedita
Nivedita 2023-11-14
编辑:Nivedita 2023-11-14
Hello Srushti,
I understand that you want the text alignment inside the text area to be vertically and horizontally in center.
You can create a workaround by adjusting the "Position" property of the text box and manipulating the "Text" property to create the appearance of vertical center alignment. Here's a simple example:
function startupFcn(app)
%Create a TextArea
app.TextArea = uitextarea(app.UIFigure);
app.TextArea.Position = [100 100 200 200];
app.TextArea.HorizontalAlignment = 'center';
%Create a string with newline characters to simulate vertical centering
app.TextArea.Value = {''; '';'';'';'';'Your Text'; ''};
end
In this example, the "Value" property of the TextArea is set to a cell array of strings. The first few and last strings are empty, effectively pushing the text string ('Your Text') towards the center of the TextArea. You may need to adjust the number of empty strings based on the height of your TextArea and the size of your text.
For more information on the properties of "TextArea", you can refer to the followiung documentation link:
I hope this helped!
Regards,
Nivedita.

类别

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