我下面有一张图像,有两个视图分别用深绿色和绿色表示。如何在深绿色之上制作绿色,因为我们可以看到部分深绿色区域被绿色覆盖了?
这是我的简单代码
<?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>
答案 0 :(得分:0)
使用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 >