rearrange layout and set top and bottom paddings according to parameters