Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/197.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
Java 线性布局内元素的定位_Java_Android_Xml_Kotlin_Android Linearlayout - Fatal编程技术网

Java 线性布局内元素的定位

Java 线性布局内元素的定位,java,android,xml,kotlin,android-linearlayout,Java,Android,Xml,Kotlin,Android Linearlayout,我有个问题 在线性布局中是否可能有两个元素,一个在另一个之上 这是我实际的XML线性布局。实际上,我有一个LinearLayout,其中包含元素列表(RecyclerView)和一个简单的“打开”按钮: <LinearLayout android:id="@+id/linearbox" android:layout_width="match_parent" android:layout_height="wrap_content" android:orient

我有个问题

在线性布局中是否可能有两个元素,一个在另一个之上

这是我实际的XML线性布局。实际上,我有一个LinearLayout,其中包含元素列表(RecyclerView)和一个简单的“打开”按钮:

<LinearLayout
    android:id="@+id/linearbox"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical">

    <!-- Start RecyclerView -->
    <android.support.v7.widget.RecyclerView
        android:id="@+id/recyclerview"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_gravity="center_horizontal" />

    <!-- Include Open Button -->
    <include layout="@layout/open_button" />

</LinearLayout>

我想在我的元素列表上添加一个视图,我已经做了布局。我现在只想把它包括在我的列表中:

<include layout="@layout/open_button" />


谢谢

正如Avijit Karmakar所建议的那样,你不能使用线性布局,你必须使用FrameLayout,
因为这最适合于那种您希望一个视图优于另一个视图的需求。 只需将根布局更改为FrameLayout

<FrameLayout
            android:id="@+id/linearbox"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical">

                <!-- Start RecyclerView -->
                <android.support.v7.widget.RecyclerView
                    android:id="@+id/recyclerview"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:layout_gravity="center_horizontal" />

            <!-- Include Open Button -->
            <include layout="@layout/open_button" />
        </FrameLayout>


在线性布局中,不能将一个视图置于另一个视图之上。为此,您必须使用FrameLayout或RelativeLayout。谢谢@AvijitKarmakar