2017-08-28 11 views
0

私は内部にRecyclerViewを含むSwipeRefreshLayourを含むフラグメントを持っています。swipeerefreshlayout内のrecyclerviewにオーバースキャン効果が表示されません

このrecyclerViewは、オーバースクロール効果を表示しません。私が使用し、このようなことをたくさん試してみました:スタイルを経由して

android:isScrollContainer="true" 
android:overScrollMode="always" 

カスタムカラーは動作しませんが

fadingEdge、fadingEdgeLengh、requiresFadingEdge ...

スワイプ働いてリフレッシュし、それがこのことを示しします

:私はこれを取得しない

enter image description here

この機能の私の実装では

enter image description here

+0

レイアウトやアクティビティ/フラグメントコード(または少なくともこの問題に関連する部分)を投稿できる場合は、本当に役に立ちます。 – Jlange

+0

これはレイアウトやコードの問題ではなく、アンドロイドスタジオテンプレート(ScrollingActivity)を使用してデフォルトのアクティビティを作成しました。私のアプリではオーバースキャン効果がありません。 – Dahnark

+0

さて、既定のScrollingActivityで新しいアプリケーションを作成しましたが、これと同じScrollingActivityの古いアプリケーションでオーバースキャンが発生したときにオーバースキャンされませんでした。最新のサポートライブラリでAndroid Studio 3.0ベータ2を使用しています。おそらく、このバグの原因は何ですか? – Dahnark

答えて

0

、(オーバースクロール上部と下部の両方に取り組んでいる)、私はこのように私のレイアウトを持っている:

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

<...<custom view>...SwipeRefreshWrapper 
    android:id="@+id/swiperefresh_layout" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 

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

     <RecyclerView 
      android:id="@+id/video_recyclerview" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent"/> 

     <include layout="@layout/include_video_list_empty_view"/> 
     <include layout="@layout/include_watchlist_empty_view"/> 

    </FrameLayout> 
<SwipeRefreshWrapper> 

そして、私のSwipeRefreshWrapper実装次のようになります。私の断片Iのセットアップで次に

/** 
* This Class ensures that a SwipeRefreshLayout will only refresh if the 
* list it wraps cannot scroll up anymore, (that it is at the top). Otherwise 
* when the user attempts to scroll up from the middle of the list, the refresh 
* will trigger. This is necessary for custom List implementations, (or 
* RecyclerViews), only. 
*/ 
public class SwipeRefreshWrapper extends SwipeRefreshLayout { 
    private ScrollResolver mScrollResolver; 

    public SwipeRefreshWrapper(Context context) { 
     super(context); 
    } 

    public SwipeRefreshWrapper(Context context, AttributeSet attrs) { 
     super(context, attrs); 
    } 

    public void setScrollResolver(ScrollResolver scrollResolver) { 
     mScrollResolver = scrollResolver; 
    } 

    @Override 
    public boolean canChildScrollUp() { 
     if(mScrollResolver != null){ 
      return mScrollResolver.canScrollUp(); 
     } else { 
      return super.canChildScrollUp(); 
     } 
    } 

    public static interface ScrollResolver{ 
     public boolean canScrollUp(); 
    } 
} 

SwipeRefreshLayout:

/** 
* Initializes PullToRefresh handler 
*/ 
private void initPullToRefresh() { 
    mSwipeRefreshLayout = (SwipeRefreshWrapper) mView.findViewById(R.id.swiperefresh_layout); 
    mSwipeRefreshLayout.setColorSchemeResources(R.color.colorPrimary, R.color.colorAccent); 

    mSwipeRefreshLayout.setScrollResolver(new SwipeRefreshWrapper.ScrollResolver() { 
     @Override 
     public boolean canScrollUp() { 
      return mVideoRecycler.canScrollVertically(-1); 
     } 
    }); 

    mSwipeRefreshLayout.setOnRefreshListener(...) 
} 
+0

スクロールアクティビティを作成しました。このアクティビティもネストされたスクロールでオーバースキャンされませんでした。 私はアプリにオーバースクロール効果がない理由を理解していません – Dahnark

+0

多くのアイテムがあるメニューではオーバースキャン効果があるので、recyclerviewやnestedscrollviewのようなアクティビティ要素にしかありません – Dahnark

+0

このアクティビティのコードを投稿できますか?おそらくスクロールイベントをオーバーライドしていますか? – Jlange

関連する問題