【发布时间】:2015-10-08 13:48:50
【问题描述】:
根据docs,FrameLayout 中的子视图被绘制在彼此的顶部,最近添加的视图在顶部。不过我注意到,这在 Lollipop 或更高版本中似乎不准确。例如,在以下 xml 中,按钮仍然可见,即使它应该被我的自定义视图覆盖。
值得一提的是,虽然我的自定义视图扩展了 FrameLayout,但我确实膨胀了一个子视图,所以我的 FrameLayout 不是空的。
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<Button
android:id="@+id/some_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_gravity="center"
android:text="button"/>
<mycustomframelayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#000000"/>
</FrameLayout>
知道我在这里缺少什么吗?
【问题讨论】: