Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/178.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_Android Linearlayout_Overlay - Fatal编程技术网

Java 线性布局中的覆盖浮动按钮

Java 线性布局中的覆盖浮动按钮,java,android,xml,android-linearlayout,overlay,Java,Android,Xml,Android Linearlayout,Overlay,我有一个这样的布局: 但正如您所看到的,浮动按钮没有覆盖编辑文本。在线性布局中有什么方法可以做到这一点吗?我不能使用其他布局 我已经看到了很多答案,但它们都使用了RelativeLayout或FrameLayout 这是我的xml,浮动按钮在末尾- <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools

我有一个这样的布局:

但正如您所看到的,浮动按钮没有覆盖编辑文本。在线性布局中有什么方法可以做到这一点吗?我不能使用其他布局

我已经看到了很多答案,但它们都使用了RelativeLayout或FrameLayout

这是我的xml,浮动按钮在末尾-

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:weightSum="10"
    android:orientation="vertical"
    tools:context=".Start">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1">

        <Button
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:text="New Button"
            android:id="@+id/button" />

    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1">

        <Button
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:text="New Button"
            android:id="@+id/button2" />

    </LinearLayout>

    <EditText
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="4"
        android:layout_gravity="center_horizontal"
        android:id="@+id/editText" />

    <EditText
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="4"
        android:layout_gravity="center_horizontal"
        android:id="@+id/editText2" />

    <!--Overlay this image -->

    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/imageView"
        android:src="@drawable/ic_mic"
        android:layout_gravity="right" />

</LinearLayout>
这是我想要的样子-

使用FrameLayout,如以下代码所示:

<FrameLayout
  android:layout_width="wrap_content"
  android:layout_height="wrap_content" >

<ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/imageView"
        android:src="@drawable/ic_mic"/>
</FrameLayout>

所有其他答案都使用FrameLayout或RelativeLayout是有原因的。LinearLayout的名称为Linear。它不支持层。请在您阅读的其他答案中使用FrameLayout或RelativeLayout。使用FrameLayout可实现此目的如果仅使用线性布局无法实现您的愿望,则必须使用FrameLayout。好的。谢谢你的建议。