Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/cmake/2.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 SwipeRefreshLayout+;另一种观点_Android_Swiperefreshlayout - Fatal编程技术网

Android SwipeRefreshLayout+;另一种观点

Android SwipeRefreshLayout+;另一种观点,android,swiperefreshlayout,Android,Swiperefreshlayout,我的布局设置如下所示: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="wrap_content"&g

我的布局设置如下所示:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

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

    <android.support.v4.widget.SwipeRefreshLayout
        android:id="@+id/swipe_refresh"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
        <com.my.SubView
            android:id="@+id/my_list_subview"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="@color/white" />
    </android.support.v4.widget.SwipeRefreshLayout>

    <TextView
        android:id="@+id/text_content"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:padding="@dimen/padding_medium"
        android:layout_margin="@dimen/padding_medium"
        android:text="Hello"
        android:textSize="14sp"
        android:maxLines="3"/>

</LinearLayout>

上图中的蓝线是文本视图所在的位置。我有什么遗漏吗?这似乎是一个如此简单的问题,太可笑了

图2回应@Tomar的回答,试试这个

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

    <include layout="@layout/my_toolbar"
        android:id="@+id/top_layout"/>

    <android.support.v4.widget.SwipeRefreshLayout
        android:id="@+id/swipe_refresh"
        android:layout_width="match_parent"
        android:layout_above="@+id/text_content"
        android:layout_below="@+id/top_layout"
        android:layout_height="wrap_content">
        <com.my.SubView
            android:id="@+id/my_list_subview"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="@color/white" />
    </android.support.v4.widget.SwipeRefreshLayout>

    <TextView
        android:id="@+id/text_content"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:padding="@dimen/padding_medium"
        android:layout_margin="@dimen/padding_medium"
        android:text="Hello"
        android:textSize="14sp"
        android:layout_alignParentBottom="true"
        android:maxLines="3"/>

</RelativeLayout>

如上所述,我使用ConstraintLayout解决了这个问题,如下所示。我不知道为什么我需要在滑动刷新布局中使用较大的底部边距和填充,使其位于文本上方。没有这些,它就不能工作

<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@color/white"
    xmlns:app="http://schemas.android.com/apk/res-auto">

    <include layout="@layout/toolbar"
        android:id="@+id/my_toolbar"
        android:layout_height="wrap_content"
        android:layout_width="0dp"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintEnd_toEndOf="parent"/>

    <android.support.v4.widget.SwipeRefreshLayout
        android:id="@+id/swipe_refresh"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_marginBottom="@dimen/padding_large"
        android:paddingBottom="@dimen/padding_super_large"
        app:layout_constraintTop_toBottomOf="@+id/my_toolbar"
        app:layout_constraintBottom_toTopOf="@+id/text_content"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintEnd_toEndOf="parent">
        <com.my.SubView
            android:id="@+id/my_list_subview"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:background="@color/white"/>
    </android.support.v4.widget.SwipeRefreshLayout>

    <EditText
        android:id="@+id/text_content"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:background="@color/white"
        android:hint="@string/write_message"
        android:textSize="14sp"
        android:maxLines="3"
        android:padding="@dimen/padding_medium"
        android:paddingLeft="@dimen/padding_large"
        app:layout_constraintTop_toBottomOf="@+id/swipe_refresh"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintBottom_toBottomOf="parent"
        tools:visibility="visible"
        tools:layout_editor_absoluteX="0dp" />

</android.support.constraint.ConstraintLayout>



尝试使用上面的layout\u从下到上构建布局。不,不起作用。无论哪种情况,滑动刷新布局都希望占据整个空间,直到底部。如果我将textview向上移动,它会正确显示,但不会显示在下方。请执行一项操作,将父布局高度作为match_parent。它可能只是在预览中,请尝试运行应用程序?也尝试调整高度。(编辑和下面的答案)。如图2所示(添加到主要问题中,因为我无法将其添加到评论中)。@GreenBee try Now谢谢。在下面添加
android:layout_=“@+id/top_layout”
有效!我不喜欢RelativeLayouts,但显然我不能让它与Linear一起工作!事实上,我用一种混乱的方式与ConstraintLayout合作。
  <androidx.constraintlayout.widget.ConstraintLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent">

        <androidx.swiperefreshlayout.widget.SwipeRefreshLayout
           android:id="@+id/srl_reload_list"
           android:layout_width="0dp"
           android:layout_height="0dp"
           app:layout_constraintBottom_toBottomOf="parent"
           app:layout_constraintLeft_toLeftOf="parent"
           app:layout_constraintRight_toRightOf="parent"
           app:layout_constraintTop_toBottomOf="parent">

        <androidx.recyclerview.widget.RecyclerView
            android:id="@+id/recyclerView_openOrderList"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:fitsSystemWindows="true" />
    </androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
</androidx.constraintlayout.widget.ConstraintLayout>