Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Center Align an Object or Text into Another Object or Shape Layer

New Here ,
Nov 02, 2022 Nov 02, 2022

Hi, How can I center align an object or a text into another object in After effects? For exmaple I need to center align the texts in the attached picture inside the respective yellow boxes. How can I do that?

TOPICS
How to
10.0K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Nov 02, 2022 Nov 02, 2022

Alignment for text layers is controlled by how you create it - just like in any other Adobe program. Similarly, alignment options will appear in the top tool bar with multiple layers selected as in other Adobe programs as well. Anything more fancy than that can be achieved by adjusting anchor points and positions, using scripts and expressions, but without any info about what teh project needs to do and how adaptable it needs to be there seems little point in confusing you by pointing to these things. It would probably be a good idea to start by actually reading the online help on some basics.

 

Mylenium

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 02, 2022 Nov 02, 2022

Hello Mylenium, My question is pretty simple. How can I center align the text (14, 30, 60) in the attached picture into the Yellow boxes, as 14 in the first, 30 in the second & 60 in the last?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Nov 02, 2022 Nov 02, 2022

As per my first reply - select the text and box, use the alignment options in the horizontal toolbar.

 

Mylenium 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 02, 2022 Nov 02, 2022

In this case, make sure your text is center-aligned in the Paragraph panel, then align it to the box. 
You could do this using the Align panel (set "Align Layers to:" to Selection).

You could also simply make sure the X Position values match (assuming the box Anchor Points are also centered). 

 

If you need these to stay centered within the boxes as they move around, you'll need to parent the text to the box, or vice-versa. 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 02, 2022 Nov 02, 2022

Shape layers and Text layers have the ability to read the left edge and top edge of the object as well as the width and height. You can use sourceRectAtTime() to center a text layer below a shape or a shape layer under a Text layer. Here's the expression for centering a shape layer over a text layer, no matter how the paragraph justification or baseline shift has been set.

 

L = thisComp.layer(index - 1);
S = L.sourceRectAtTime();
W = S.width/2 + S.left;
H = S.height/2 + S.top;
x = L.position[0] + W;
y = L.position[1] + H;
[x, y]

 

If you want the Text layer to be centered above a layer with the Anchor Point in the center of the layer, then apply this expression to the Text layer's position;

 

T = thisLayer.sourceRectAtTime();
xC = T.width/2 - T.left;
yC = T.height + T.top /2;
L = thisComp.layer(index + 1);
[xC - T.width, yC] + L.position

 

 If you are dealing with Shape layers for the background, you can also incorporate sourceRectAtTime to adjust the size of the shape layer.

 

One of those expressions will solve your problem if the text layer is just above the layer you want to act as the background.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 19, 2025 Apr 19, 2025
LATEST

I'm kinda late, but the way i do that is i just select both the shape and the text, and align them to center of the comp, then i just free move them to where i want to move the box with the text inside! 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines