Filter löschen
Filter löschen

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

32 Ansichten (letzte 30 Tage)
SRUSHTI KHATAU am 2 Feb. 2022
Bearbeitet: Nivedita am 14 Nov. 2023
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 Kommentare
Rik am 2 Feb. 2022
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 am 2 Feb. 2022
Okay. Thank you for replying. I will try this option. But, the problem is I have to use large number of Text Area.

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Nivedita am 14 Nov. 2023
Bearbeitet: Nivedita am 14 Nov. 2023
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'; ''};
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!


Mehr zu Migrate GUIDE Apps finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by