I read the documentation, but I am not able get when should I use which?
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