android - 如何使用带有 recyclerview 的滑动刷新

标签 android

我使用了带有 recyclerivew 的刷卡刷新。但我看到一个问题。我无法向上滚动我的 recyclerivew。我可以正常向下滚动 recyclerview,但每次我尝试向上滚动时,它都不会向上滚动,它正在运行快速刷新功能,但我还没有滚动到顶部。 这是我的 xml

<android.support.v4.widget.SwipeRefreshLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_marginBottom="-5dp"
    android:id="@+id/swiperefresh"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">
    <LinearLayout
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:orientation="vertical"
      android:id="@+id/buslayout"
      android:focusableInTouchMode="true"
      >

      <TextView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_marginTop="50dp"
        android:layout_gravity="center"
        android:gravity="center"
        android:text="Loading..."
        android:id="@+id/info"
        android:visibility="visible"/>
      <android.support.v7.widget.RecyclerView
        android:id="@+id/business_recycle"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />
    </LinearLayout>
</android.support.v4.widget.SwipeRefreshLayout>

最佳答案

试试这个:

 <FrameLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_marginBottom="-5dp"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

         <TextView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_marginTop="50dp"
            android:layout_gravity="center"
            android:gravity="center"
            android:text="Loading..."
            android:id="@+id/info"
            android:visibility="visible"/>

        <android.support.v4.widget.SwipeRefreshLayout
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:orientation="vertical"
          android:id="@+id/swiperefresh"
          android:focusableInTouchMode="true"
          >
          <android.support.v7.widget.RecyclerView
            android:id="@+id/business_recycle"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />
        </android.support.v4.widget.SwipeRefreshLayout>
    </FrameLayout>

关于android - 如何使用带有 recyclerview 的滑动刷新,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41309922/

相关文章:

android - 尝试在 Gingerbread 设备上运行时出现 INSTALL_FAILED_OLDER_SDK

android - 如何在 Eclipse for Android 中更改 Control+Space 自动完成快捷键

java - Android中的SQLite如何更新特定行

Android BroadcastReceiver处理多条消息

android - 了解谷歌开发者控制台

android - Ionic + Cordova Android 构建错误 - 找不到 tools.jar

java - 从 JSON 对象中提取字符串

Android: java.lang.NoSuchMethodError: Landroid\/os\/调用 FacebookSdk.sdkInitialize() 时的处理程序

android - No Such Column Sugar ORM 仅在发布版本中

Android - 按钮背景颜色缩小按钮的高度