2

CoordinatorLayout内にNestedScrollViewがあり、それにrecyclerViewが含まれています。非常に長い断片全体にスクロールの勢いはなく、私はそれを修正するために何ができるのかよくわかりません。私はかつて高級Androidバージョンでこの問題を抱えており、問題を解決するためにAPI 19 Scrollview no momentum

android:nestedScrollingEnabled="false" 

を含めることができました。しかし、これはapi 21で追加され、私のプロジェクトは19+をサポートしています。私のアプリはまだ、この断片のapi 19デバイスの勢いはありません。以下は

は私のxmlです:

<android.support.design.widget.CoordinatorLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    android:layout_height="match_parent" 
    android:layout_width="match_parent" 
    android:background="@color/primary_color" 
    android:fitsSystemWindows="true"> 

<android.support.v4.widget.NestedScrollView 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     app:layout_behavior="android.support.design.widget.AppBarLayout$ScrollingViewBehavior"> 

    <android.support.percent.PercentRelativeLayout 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:nestedScrollingEnabled="false"> 

     <ImageView 
       android:id="@+id/logo" 
       android:src="@drawable/logo" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_marginTop="@dimen/profile_margin_medium_huge" 
       android:layout_marginBottom="46dp" 
       android:layout_marginRight="@dimen/activity_horizontal_margin" 
       android:layout_marginLeft="@dimen/activity_horizontal_margin" 
       android:layout_alignParentEnd="true"/> 

     <TypefaceTextView 
       android:id="@+id/textview_title" 
       android:layout_below="@id/logo" 
       android:text="@string/title" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       style="@style/myStyle" 
       android:layout_marginLeft="@dimen/activity_horizontal_margin" 
       android:layout_marginRight="@dimen/activity_horizontal_margin" 
       android:layout_marginBottom="16dp" 
       android:layout_alignParentLeft="true"/> 

     <TypefaceTextView 
       android:id="@+id/textview_byline" 
       android:text="@string/byline" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       style="@style/myStyle" 
       android:layout_below="@id/textview_title" 
       android:layout_marginLeft="@dimen/activity_horizontal_margin" 
       android:layout_marginRight="@dimen/activity_horizontal_margin" 
       android:layout_marginBottom="40dp"/> 

     <RadioGroup 
       android:id="@+id/radiogroup_filter" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:orientation="horizontal" 
       android:layout_below="@id/textview_byline" 
       android:layout_alignParentRight="true" 
       android:layout_marginLeft="@dimen/activity_horizontal_margin" 
       android:layout_marginRight="@dimen/activity_horizontal_margin" 
       android:layout_marginBottom="@dimen/activity_vertical_margin"> 

      <TypefaceRadioButton 
        android:id="@+id/button_filter_new" 
        android:text="@string/filter_new" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        style="@style/buttonStyleRadio" 
        android:theme="@style/ButtonSecondary" 
        android:button="@null"/> 

      <TypefaceRadioButton 
        android:id="@+id/button_filter_history" 
        android:text="@string/filter_history" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        style="@style/ButtonStyleRadio" 
        android:theme="@style/ButtonSecondary" 
        android:layout_alignParentRight="true" 
        android:button="@null"/> 

     </RadioGroup> 
     <android.support.v7.widget.RecyclerView 
       android:id="@+id/recyclerview" 
       android:nestedScrollingEnabled="false" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:layout_below="@id/radiogroup_filter" 
       android:layout_marginLeft="@dimen/activity_horizontal_margin" 
       android:layout_marginRight="@dimen/activity_horizontal_margin" 
       android:layout_marginBottom="50dp"/> 
     <android.support.percent.PercentRelativeLayout 
       android:id="@+id/container_links" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:layout_below="@id/recyclerview" 
       android:visibility="gone"> 
      <ImageView 
        android:id="@+id/image_link_1" 
        app:layout_widthPercent="100%" 
        app:layout_aspectRatio="158%" 
        android:scaleType="centerCrop" 
        android:layout_alignParentTop="true"/> 
      <TypefaceTextView 
        android:id="@+id/text_link_1" 
        android:text="@string/text_1" 
        app:layout_widthPercent="100%" 
        app:layout_aspectRatio="158%" 
        android:gravity="bottom|left" 
        android:paddingLeft="@dimen/activity_horizontal_margin" 
        android:paddingRight="@dimen/activity_horizontal_margin" 
        android:paddingTop="32dp" 
        android:paddingBottom="32dp" 
        style="@style/myStyle" 
        android:layout_alignParentTop="true"/> 
      <ImageView 
        android:id="@+id/image_link_2" 
        app:layout_widthPercent="100%" 
        app:layout_aspectRatio="158%" 
        android:scaleType="centerCrop" 
        android:layout_below="@id/image_link_1"/> 
      <TypefaceTextView 
        android:id="@+id/text_link_2" 
        android:text="@string/text_2" 
        app:layout_widthPercent="100%" 
        app:layout_aspectRatio="158%" 
        android:gravity="bottom|right" 
        android:paddingLeft="@dimen/activity_horizontal_margin" 
        android:paddingRight="@dimen/activity_horizontal_margin" 
        android:paddingTop="32dp" 
        android:paddingBottom="32dp" 
        android:layout_below="@id/image_link_1" 
        style="@style/myStyle"/> 
     </android.support.percent.PercentRelativeLayout> 
    </android.support.percent.PercentRelativeLayout> 
</android.support.v4.widget.NestedScrollView> 

+0

あなたはあなたのアプリケーションにonTouchまたはonDispatchTouchをオーバーライドしていますか? –

+0

@LeandroBorgesFerreira私はそうではありません:/ – kjanderson2

+0

グレードファイルとビルドツールのサポートライブラリを更新してください –

答えて

4

私は私のテストプロジェクトにあなたの症状を再作成することができました。ことを知っている

final RecyclerView recyclerView = (RecyclerView) findViewById(R.id.recyclerview); 
recyclerView.setOnFlingListener(new RecyclerView.OnFlingListener() { 
     @Override 
     public boolean onFling(int velocityX, int velocityY) { 
      recyclerView.dispatchNestedFling(velocityX, velocityY, false); 
      return false; 
     } 
    }); 

私はRecyclerViewに情事リスナーを追加し、onFling()で、私はdispatchNestedFling()を呼び出した親を聞かせするために:私はそれが活動のためのonCreate()に次のコードを追加する固定しました飛行が起こっている。親はその後、遊戯を消費するか、または子供の遊戯を観察することができる。バージョン22.1.0 ブールdispatchNestedFling(フロートvelocityX、 フロートvelocityY、消費 ブーリアン)ネストされたスクロール親に羽織るディスパッチで添加

をdispatchNestedFling

https://developer.android.com/reference/android/support/v4/view/NestedScrollingChild.html#dispatchNestedFling(float, float, boolean)

このメソッドは、ネストされたスクロールする子の がフリングの適切な条件を検出したことを示すために使用する必要があります。一般に、これは、 スクロール可能な軸に沿った最小飛行速度に一致またはそれを超えるスクロール方向の速度でタッチ・スクロールが終了したことを意味する を意味します。

ネストされたスクロールする子ビューが通常は飛んでいるが、それ自身のコンテンツの端にある の場合、このメソッドを使用して、 を入れ子にしたスクロール親に代入することができます。親は、任意選択的に、ふくらはぎを消費するか、または子供の遊びを観察することができる。 。

これは私のエミュレータAPI 19を実行しています:明らかに、YMMV。

+0

よろしく!それは私のために働いた! – kjanderson2

+0

良い!私は助けてくれてうれしい! –

+0

私のために働いた...ありがとう男!。 –

1

簡単な方法があります:

は、Java

recyclerView.setNestedScrollingEnabled(false); 

Kotlin

recyclerView.isNestedScrollingEnabled = false 
+0

あなたはその質問を読んだことがありますか?私はそれを試みたが、それはAPI 19のために働かない...受け入れられた答えが働いた。 – kjanderson2

+0

@ kjanderson2 Dude、それはXMLでは動作しませんが、onCreateで設定したときに機能します。 –

+0

あなたは絶対に正しいです!それは働く(y) –

関連する問題