title: Why FrameLayout isn't setting Z order correctly in my layout?
body: <p>I have the following layout (here is presented much simpler design):</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"
      xmlns:tools="http://schemas.android.com/tools"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      app:layout_behavior="@string/appbar_scrolling_view_behavior"
      tools:showIn="@layout/activity_main"&gt;
      &lt;FrameLayout
          android:orientation="horizontal"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_alignParentRight="true"
          android:layout_alignParentEnd="true"
          &gt;
          &lt;Button
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:text="Hey, badge!"
              android:layout_margin="10dp"
              /&gt;
          &lt;TextView
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:text="AAAAA"
              android:layout_margin="10dp"
              android:textSize="12sp"
              android:background="#ff00ff"
              android:padding="10dp"
              android:layout_gravity="top|end"
              /&gt;
      &lt;/FrameLayout&gt;
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>I wish to set TextView with text "AAAA" to act as a badge for Button, i.e. to be placed over the button in its upper right corner, which is not the case.</p>
  
  <p>Instead, when I try this code on HTC One M7 with Lollipop, or on Genymotion Nexus 6 with Lollipop, screen looks something like this:</p>
  
  <p><a href="https://i.stack.imgur.com/8AnSQ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/8AnSQ.png" alt="Screenshot of views badly placed"></a></p>
  
  <p>When I try the same code on Genymotion Nexus 5 with KitKat, everything looks as expected, i.e. <strong>first view (button) is shown underneath badge (textview)</strong></p>
  
  <p>Does anyone have any clue what could be wrong here?</p>
  
  <p>Thanks, 
  Deveti</p>