Textview on(above) Button, doesn't work in Android 5(API 21)

人盡茶涼 提交于 2019-12-03 11:07:38

Yes. It is big chnage in Android L(API 21). There is new thing - Elevation, it is something like z-index in HTML. So to fix this bug you need use android:elevation="100dp" OR android:translationZ="100dip" for view that should be on top. So correct code is:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/rlBottom"
android:layout_width="fill_parent"
android:layout_height="match_parent" >



<FrameLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:background="#00FF00">

    <Button
        android:id="@+id/bVio"
        android:layout_width="wrap_content"
        android:layout_height="50dip"
        android:text="VIO"></Button>

    <TextView
        android:id="@+id/bVio_count"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="00"
        android:textSize="12dip"
        android:textColor="#FFFFFF"
        android:background="@drawable/rounded_textbox"
        android:elevation="100dp"/>

    </FrameLayout>

</RelativeLayout>
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!