我正在寻找一种方法,以便在拉动时使我的recycleView弹性在顶部。让我告诉你一个我想要的图像:
https://raw.githubusercontent.com/baoyongzhang/android-PullRefreshLayout/master/demo.gif
所以你可以从那个gif看到,当用户拉下列表的顶部时,它会产生弹性反弹效果。我如何实现这一目标?我想要这种影响所以我的swipeRefreshLayout只是通过到达顶部而不会轻易触发。我希望他们实际上是PULL刷新而不是到达顶部。我的appbar布局现在看起来像这样:
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/main_content"
android:layout_width="match_parent"
android:fitsSystemWindows="false"
android:layout_height="match_parent">
<android.support.design.widget.AppBarLayout
android:id="@+id/id_appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/white">
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/collapsing_toolbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:contentScrim="@color/white"
app:layout_scrollFlags="scroll|exitUntilCollapsed"
app:titleEnabled="false">
<com.mobile..UI.customViews.CategoryBanner
android:id="@+id/shortcutbanner"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_collapseMode="parallax" />
<include layout="@layout/toolbar" />
</android.support.design.widget.CollapsingToolbarLayout>
<android.support.design.widget.TabLayout
android:id="@+id/tabLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:tabGravity="fill"
app:tabMode="fixed"
android:elevation="6dp"
app:tabSelectedTextColor="@android:color/darker_gray"
app:tabTextColor="@color/black" />
</android.support.design.widget.AppBarLayout>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="fill_vertical"
android:orientation="vertical">
<com.mobile.UI.customViews.HomePageViewPager
android:id="@+id/pager"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="fill_vertical"
/>
</LinearLayout>
</FrameLayout>
</android.support.design.widget.CoordinatorLayout>
在选项卡内部,我有以下的recyclerView:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<android.support.v4.widget.SwipeRefreshLayout
android:id="@+id/swipefeedRefreshLayout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.mobile.UI.customViews.VelocityControlRecyclerView
android:id="@+id/recyclerView"
android:layout_marginTop="0dp"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</android.support.v4.widget.SwipeRefreshLayout>
</LinearLayout>
在我的活动中,我试着调用它,但它不起作用:
mRecyclerView.setOverScrollMode(View.OVER_SCROLL_ALWAYS);