Canvas Scaler is not applied to the dynamically added canvas text

Hallo everyone. To scale the canvas text and images for different resolutions I am using canvas scaler. But my Text object which I instantinated in the runtime and added to the canvas is not scaled. Does anybody know what is the problem?

I had the same problem.
I solved it by setting worldPositionStays to false as the second parameter to SetParent.

newText.transform.SetParent(canvas.transform, false);

If you consider using Unity UI components, there is an option for Text UI called as ‘Best Fit’, which will convert the text to suitable size, and filling up the necessary text space. Try it out.