Difference in behavior of android:gravity="center_vertical" for RelativeLayout and LinearLayout
<p>Let's say I have two views that I want to center vertically. The first view is bigger than the second view.</p>

<p>I noticed that if I place theses two views inside a <code>RelativeLayout</code> with properties <code>layout_height="wrap_content"</code> and <code>android:gravity="center_vertical"</code> nothing happens. This is what I get :</p>

<p><a href="https://i.stack.imgur.com/P0VJY.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/P0VJY.png" alt="enter image description here"></a></p>

<p>In the opposite, if I place these two views inside a <code>LinearLayour</code> with properties <code>layout_height="wrap_content"</code> and <code>android:gravity="center_vertical"</code> the views are centered vertically :</p>

<p><a href="https://i.stack.imgur.com/6KBwO.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/6KBwO.png" alt="enter image description here"></a></p>

<p>Lastly, if I place these two views inside a <code>RelativeLayout</code> with properties <code>layout_height</code> with a fixed height and <code>android:gravity="center_vertical"</code> I get the same result as the <code>LinearLayout</code>. The views are centered vertically.</p>

<p>I would expect the views to be centered vertically in each case. Do you know the reason for this difference?</p>