Android layout renders wrong on Marshmallow
<p>I have just noticed that my Android app layout is broken when displayed on Marshmallow. It is fine on Nexus 5 with Android 5.1.1 but it renders wrong on Nexus 5 and Nexus 5x with the latest version of Android.</p>

<p>The layout consist of little triangle (see red part) aligned to the bottom and above it there is some view (white) that should span all available height of its parent (grey part).</p>

<p>And this is how it renders on Android 5.1.1 (Nexus 5):</p>

<p><a href="https://i.stack.imgur.com/gXb1f.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/gXb1f.png" alt="nexus5_android5_fine"></a></p>

<p>while on Android 6.0 (Nexus 5 and Nexus 5X) it is:</p>

<p><a href="https://i.stack.imgur.com/pSiOI.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/pSiOI.png" alt="nexus5x_android6_bad"></a></p>

<p>The problem looks like the red view doesn't respect its parent alignment (bottom, right) and it makes the white view (which is placed above) to disappear.</p>

<p>The simplified layout of the grey view and its children is (I have added some background colours to see the view bounds):</p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"    
    android:background="#777777"&gt;

    &lt;View 
        android:id="@+id/preview_triangle"
        android:layout_width="@dimen/preview_triangle_width"
        android:layout_height="@dimen/preview_triangle_height"
        android:layout_marginRight="@dimen/preview_triangle_margin_right"
        android:layout_alignParentRight="true"
        android:layout_alignParentBottom="true"
        android:background="#ff0000"/&gt;

    &lt;LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_above="@id/preview_triangle"   
        android:orientation="horizontal"&gt;
        &lt;View
            android:layout_width="@dimen/preview_margin_horizontal"
            android:layout_height="match_parent"/&gt;
        &lt;FrameLayout
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:padding="3dp"
            android:background="@drawable/round_rectangle_white_radius_3dp"&gt;
            &lt;WebView
                android:id="@+id/preview_webview"
                android:layout_width="match_parent"
                android:layout_height="match_parent"/&gt;
        &lt;/FrameLayout&gt;

        &lt;FrameLayout
            android:id="@+id/preview_close"
            android:layout_width="@dimen/preview_margin_horizontal"
            android:layout_height="@dimen/preview_margin_horizontal"&gt;
            &lt;ImageView          
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="left|top"
                android:layout_marginLeft="@dimen/preview_close_margin_left"
                android:src="@drawable/icn_close"
                android:contentDescription="@null"/&gt;    
        &lt;/FrameLayout&gt;
    &lt;/LinearLayout&gt;      
&lt;/RelativeLayout&gt;
</code></pre>

<p>The above layout is placed into separate preview.xml file and then included into main layout like this:</p>

<pre><code>&lt;include
        android:id="@+id/fragment_main_loyalty_preview_container"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_below="@id/fragment_main_loyalty_logo_container"
        android:layout_above="@id/fragment_main_loyalty_buttons_container"
        android:layout_marginTop="@dimen/fragment_main_loyalty_preview_container_margin_top"
        android:layout_marginBottom="@dimen/fragment_main_loyalty_preview_container_margin_bottom"      
        android:visibility="visible"
        layout="@layout/preview"/&gt;
</code></pre>

<p><strong>UPDATE</strong></p>

<p>The problem disappears if I replace hosting ScrollView with FrameLayout or so.</p>

<p>I really don't get it why the intermediary parent renders fine and its child is affected by the top most parent :)</p>

<p>And the situation can be reproduced inside Eclipse just by switching target API in the designer.</p>

<p><strong>UPDATE - SIMPLIFIED TEST CASE</strong></p>

<p>Below is the simplest layout I was able to create and reproduce my problem.
Basically the red area should be placed between green and blue ones.
The height of the red area should match the space available between green and blue views as there is another view (see @id/margin_placeholder) which height affects the distance between these two.</p>

<p>Inside the red area I wanted to put white view at the bottom of red area.
And this little white fellow renders different way on Android 6.0:</p>

<p><a href="https://i.stack.imgur.com/pBsRf.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/pBsRf.png" alt="lollipop fine"></a>
<a href="https://i.stack.imgur.com/TK8Xg.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/TK8Xg.png" alt="marshmallow bad"></a></p>

<pre><code>&lt;ScrollView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"&gt;

    &lt;RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"&gt;

        &lt;FrameLayout
            android:id="@+id/top"
            android:layout_width="match_parent"
            android:layout_height="90dp"
            android:layout_marginTop="10dp"
            android:background="#007700"/&gt;

        &lt;View
            android:id="@+id/margin_placeholder"
            android:layout_width="match_parent"
            android:layout_height="100dp"
            android:layout_below="@id/top"/&gt;

        &lt;FrameLayout
            android:id="@+id/bottom"
            android:layout_width="match_parent"
            android:layout_height="90dp"
            android:layout_below="@id/margin_placeholder"
            android:background="#000077"/&gt;

        &lt;RelativeLayout
            android:id="@+id/middle"
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_below="@id/top"
            android:layout_above="@id/bottom"
            android:layout_marginTop="10dp"
            android:layout_marginBottom="10dp"
            android:background="#770000"&gt;
            &lt;View
                android:layout_width="16dp"
                android:layout_height="8dp"
                android:layout_marginRight="16dp"
                android:layout_alignParentBottom="true"
                android:layout_alignParentRight="true"
                android:background="#ffffff"/&gt;
        &lt;/RelativeLayout&gt;       
    &lt;/RelativeLayout&gt;
&lt;/ScrollView&gt;
</code></pre>