androidandroid-framelayoutxml-layout

Incorrect FrameLayout's childs order on android 5.0 and above


Here is my XML layout code:

<FrameLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true" >

        <Button
            android:id="@+id/btn_test"
            android:layout_width="200dp"
            android:layout_height="200dp"
            android:background="@android:color/black"
            android:minHeight="0dp"
            android:minWidth="0dp" />

        <TextView
            android:id="@+id/tv_test"
            android:layout_width="40dp"
            android:layout_height="40dp"
            android:layout_gravity="center"
            android:background="@android:color/white"
            android:gravity="center"
            android:text="12"
            android:textColor="@android:color/black"
            android:textStyle="bold" />
    </FrameLayout>

As I expected the TextView will overlay on the Button, but it only working on android < 5.0. I research for all API changes about FrameLayout from developer site but still not getting exactly information. Did anyone find that? How to overlay TextView on Button via XML?


Solution

  • Finally I known the change. That is evelation . Hope this help other. http://developer.android.com/training/material/shadows-clipping.html