When you use RelativeLayout – You should use layout_centerHorizontal,layout_centerVertical,layout_centerInParent
but when you use LinearLayout , you should use gravity to align children i.e., layout_gravity and gravity.
foregroundGravity is used with foreground tag.
What is in foreground it will align according to foregroundGravity
solved When should I use layout_centerHorizontal=true and gravity=”center_horizonatal” and foregroundGravity=”centerHorizontal”?