Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/231.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 在CoordinatorView外部使用RelativeLayout_Java_Android_Android Layout_Android Coordinatorlayout - Fatal编程技术网

Java 在CoordinatorView外部使用RelativeLayout

Java 在CoordinatorView外部使用RelativeLayout,java,android,android-layout,android-coordinatorlayout,Java,Android,Android Layout,Android Coordinatorlayout,我有一个CoordinatorLayout,其中一个RecyclerView显示一些在其他布局中定义的CardView。在这个可滚动的视图下,我试图添加一个RelativeLayout,它继承文本输入字段、发送按钮等 问题是:CoordinatorLayout似乎挡住了整个屏幕,尽管我告诉过你要把内容包起来。尽管如此,还是添加了RelativeLayout(通过设置协调器高度=50dp进行测试),但不在屏幕上。这里怎么了 PS:我知道如何用android:layout\u weight=xx解决

我有一个
CoordinatorLayout
,其中一个
RecyclerView
显示一些在其他布局中定义的CardView。在这个可滚动的视图下,我试图添加一个
RelativeLayout
,它继承文本输入字段、发送按钮等

问题是:
CoordinatorLayout
似乎挡住了整个屏幕,尽管我告诉过你要把内容包起来。尽管如此,还是添加了RelativeLayout(通过设置协调器高度=50dp进行测试),但不在屏幕上。这里怎么了

PS:我知道如何用android:layout\u weight=xx解决这个问题。但这不是我想要实现的,因为如果输入更大的文本,它会阻止我的编辑文本扩展

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <android.support.design.widget.CoordinatorLayout
        android:id="@+id/data_coordinator_layout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true">

        <android.support.v7.widget.RecyclerView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            />


    </android.support.design.widget.CoordinatorLayout>

    <RelativeLayout
        android:id="@+id/delete_data_layout"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_below="@id/data_coordinator_layout">

        <EditText/>
        <Button/>
        <Button/>
        <Button/>

    </RelativeLayout>


</RelativeLayout>

其实很简单。您需要将相对布局(删除数据布局)与父布局的底部对齐。然后将协调器布局置于相对布局之上。这会导致协调器布局始终位于相对布局之上,即使Edittext展开时也是如此

这里是XML

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <android.support.design.widget.CoordinatorLayout
        android:id="@+id/data_coordinator_layout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_above="@+id/delete_data_layout">  <---- Change here

        <android.support.v7.widget.RecyclerView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"/>

    </android.support.design.widget.CoordinatorLayout>

    <RelativeLayout
        android:id="@+id/delete_data_layout"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_alignParentBottom="true">   <---- Change here

        <EditText/>
        <Button/>
        <Button/>
        <Button/>

    </RelativeLayout>

</RelativeLayout>


在“数据布局”中,你不是指宽度=匹配,高度=环绕吗?是的,正确!正如在layout.xmlsry中所看到的,我的意思是“+id/delete_data_layout”,因为我看不到相对值,所以我试图通过匹配高度来强制显示相对值。火柴和包裹似乎很有效,但我现在明白了。试着把你的协调人安排在一条直线内