[英]How to partially overlap views within a relative layout
我正在嘗試將粉紅色按鈕重疊在綠色視圖上,但是我的“ z-offset”與我想要的相反。
我要尋找的效果只能通過框架布局實現嗎?
<include layout="@layout/button"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_above="@+id/view"
android:layout_alignParentRight="true"
android:layout_marginRight="15dp"
android:layout_marginBottom="-50dp"/>
<include layout="@layout/view"
android:id="@id/view"
android:layout_height="100dp"
android:layout_width="match_parent"
android:layout_alignParentBottom="true"/>
View
s是按照在布局中列出的順序繪制的,列出的第一個View
在z軸上最遠,最后一個是最靠近z軸。 如果要將按鈕放在頂部,請在布局中最后列出該按鈕。
<include layout="@layout/view"
android:id="@id/view"
android:layout_height="100dp"
android:layout_width="match_parent"
android:layout_alignParentBottom="true"/>
<include layout="@layout/button"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_above="@+id/view"
android:layout_alignParentRight="true"
android:layout_marginRight="15dp"
android:layout_marginBottom="-50dp"/>
在相對布局中,最后添加的視圖始終位於另一個視圖之上,因此您只需要交換視圖即可
首先@layout/view
然后@layout/button
<include layout="@layout/view"
android:id="@id/view"
android:layout_height="100dp"
android:layout_width="match_parent"
android:layout_alignParentBottom="true"/>
<include layout="@layout/button"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_above="@+id/view"
android:layout_alignParentRight="true"
android:layout_marginRight="15dp"
android:layout_marginBottom="-50dp"/>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.