You cannot grab the parent size, because the size is relative to the anchors. Your “parent size” will be available as soon as the anchors of the parent are placed joined.
You can move the anchors of the object (anchorMin and anchorMax) these values also moves the object and the value range goes from 0 to 1, so if you place your anchors in the middle of the object in the editor and then in code you move them to (0.5, 0.5) using anchorMin and anchorMax, you will get your object in the center of the parent (for example).
If you can’t move the anchors or you find it over complicated, you are going to need some math. Try the “Rect Transform Extended” asset, you can move and scale things around ignoring anchors: