android xml-如何重叠两个视图
我有一个像下面这样的图像,有两个视图由深绿色和绿色表示。如何使绿色在深绿色之上,因为我们可以看到部分深绿色区域被绿色覆盖 这是我的简单代码android xml-如何重叠两个视图,android,android-layout,Android,Android Layout,我有一个像下面这样的图像,有两个视图由深绿色和绿色表示。如何使绿色在深绿色之上,因为我们可以看到部分深绿色区域被绿色覆盖 这是我的简单代码 <?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="ma
<?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 >
使用FrameLayout
作为两个视图的父视图我看不到任何更改只需交换视图,然后检查