Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/182.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
android xml-如何重叠两个视图_Android_Android Layout - Fatal编程技术网

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
作为两个视图的父视图我看不到任何更改只需交换视图,然后检查