Let's say I have two views that I want to center vertically. The first view is bigger than the second view.
I noticed that if I place theses two views inside a RelativeLayout
with properties layout_height="wrap_content"
and android:gravity="center_vertical"
nothing happens. This is what I get :
In the opposite, if I place these two views inside a LinearLayour
with properties layout_height="wrap_content"
and android:gravity="center_vertical"
the views are centered vertically :
Lastly, if I place these two views inside a RelativeLayout
with properties layout_height
with a fixed height and android:gravity="center_vertical"
I get the same result as the LinearLayout
. The views are centered vertically.
I would expect the views to be centered vertically in each case. Do you know the reason for this difference?