[英]android xml - how to overlap two view
我有一個像下面這樣的圖像,有深綠色和綠色代表兩個視圖。如何在深綠色之上制作綠色,因為我們可以看到部分深綠色區域被綠色覆蓋?
這是我的簡單代碼
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<View
android:layout_width="match_parent"
android:layout_height="300dp"
android:layout_marginStart="40dp"
android:layout_marginEnd="40dp"
android:background="@color/dark_green">
</View>
<View
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="-100dp"
android:background="@color/green">
</View>
使用 Relativelayout 作為父布局,它將工作文件
<Relativelayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<View
android:layout_width="match_parent"
android:layout_height="300dp"
android:layout_marginStart="40dp"
android:layout_marginEnd="40dp"
android:background="@color/dark_green">
</View>
<View
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="-100dp"
android:background="@color/green">
</View>
</Relativelayout >
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.