我希望我的布局在background视图下方有一个header视图,但视图与header视图重叠background了几个像素,因为它具有一定的透明度。
我知道 z 顺序是根据 XML 文件中视图的顺序确定的,所以我把,属性放在header下面。backgroundandroid:layout_above="@id/background"
但是由于我将两个维度都设置为backgroundto match_parent,所以header不可见。
我怎样才能达到我想要的?
<RelativeLayout 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">
<RelativeLayout
android:id="@+id/background"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="-5dp"
android:background="@drawable/bg" >
</RelativeLayout>
<RelativeLayout
android:id="@+id/header"
android:layout_width="match_parent"
android:layout_height="100dp"
android:layout_above="@id/background"
android:background="@drawable/bg_header" >
</RelativeLayout>
</RelativeLayout>