2

CollapsingToolbarLayoutRecyclerViewとしたいとします。Whatsappのようにします。ここで CollapsingToolbarLayoutスムーススクロールの問題を伴うAndroid RecyclerView

は、キャプチャされたビデオです: https://sendvid.com/0oi2lxx5

私が上にスクロールするときだから、それは大丈夫ですが、私はスクロールダウンしたときに、それは滑らかではありません。私はRecyclerViewとスムーズにスクロールしたいです。だからここ

がある私のprofile_activity.xml

<?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:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:fitsSystemWindows="true"> 
    <android.support.v7.widget.RecyclerView 
     android:layout_width="match_parent" 
     android:id="@+id/profile_recyclerview" 
     android:layout_height="match_parent" 
     app:layout_behavior="@string/appbar_scrolling_view_behavior" 
     android:layout_below="@+id/profileactivity_appbar" /> 

    <android.support.design.widget.AppBarLayout 
     android:id="@+id/profileactivity_appbar" 
     android:layout_width="match_parent" 
     android:layout_height="400dp" 
     android:fitsSystemWindows="true" 
     android:theme="@style/AppTheme3.AppBarOverlay"> 

     <android.support.design.widget.CollapsingToolbarLayout 
      android:id="@+id/profileactivity_collapsing_toolbar" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      app:layout_scrollFlags="scroll|exitUntilCollapsed" 
      android:fitsSystemWindows="true" 
      app:contentScrim="?attr/colorPrimary" 
      app:expandedTitleMarginStart="48dp" 
      app:expandedTitleMarginEnd="64dp"> 

      <ImageView 
       android:id="@+id/profileactivity_fullimage" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:scaleType="centerCrop" 
       android:fitsSystemWindows="true" 
       app:layout_collapseMode="parallax" 
       app:layout_scrollFlags="scroll|enterAlways|enterAlwaysCollapsed" /> 

      <android.support.v7.widget.Toolbar 
       android:id="@+id/toolbar" 
       android:layout_width="match_parent" 
       android:layout_height="?attr/actionBarSize" 
       app:popupTheme="@style/ThemeOverlay.AppCompat.Light" 
       app:layout_collapseMode="pin" /> 

     </android.support.design.widget.CollapsingToolbarLayout> 

    </android.support.design.widget.AppBarLayout> 




    <android.support.design.widget.FloatingActionButton 
     android:id="@+id/fab" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_margin="@dimen/fab_margin" 
     app:layout_anchor="@id/profileactivity_appbar" 
     app:layout_anchorGravity="bottom|right|end" 
     app:backgroundTint="@color/ColorPrimary" 
     android:src="@drawable/ic_create_white_48dp"/> 

</android.support.design.widget.CoordinatorLayout> 

私が使用しています:

compile 'com.android.support:appcompat-v7:23.4.0' 
compile 'com.android.support:support-v4:23.4.0' 
compile 'com.android.support:recyclerview-v7:23.4.0' 
compile 'com.android.support:design:23.4.0' 

がどのように私はこの問題を解決することができますか?

+0

ドロップImageViewのの 'アプリ:layout_scrollFlags'、それは問題を解決するかどうかを確認。私は、これらのフラグは 'app:layout_collapseMode'と矛盾していると思います – Sevle

+0

イメージをスクロールしようとすれば、スムーズにスクロールできますが、私はそれをrecyclerviewでスクロールできません。私はあなたが理解すると思う –

答えて

9

私は問題を解決する方法を説明します、今私のレイアウトは非常に滑らかです。

実際、私はその解決方法を知りませんが、

  • 私はすべてのandroid:fitsSystemWindows="true"の属性を削除しました。
  • CollapsingToolbarLayout,ImageViewおよびToolbarに属性app:layout_scrollFlags="scroll|enterAlways"を追加しました。
  • そして、AppBarLayoutの前にすべての要素をxmlで移動しました。

マイactivity_profile.xmlのような:

<?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" 
    xmlns:tools="http://schemas.android.com/apk/res-auto" 
    android:id="@+id/profileCoordinatorLayout" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 

<ProgressBar android:indeterminate="true" 
    android:layout_width="50dp" android:layout_height="50dp" 
    android:id="@+id/profile_activity_progress" 
    style="?android:attr/progressBarStyle" 
    android:layout_gravity="center_vertical|center_horizontal" 
    android:layout_centerVertical="true" 
    android:layout_centerHorizontal="true" 
    android:visibility="visible" /> 

<ProgressBar android:indeterminate="true" 
    android:layout_width="50dp" android:layout_height="50dp" 
    android:id="@+id/profile_activity_progress_edit" 
    style="?android:attr/progressBarStyle" 
    android:layout_gravity="center_vertical|center_horizontal" 
    android:visibility="gone" /> 


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


<android.support.v7.widget.RecyclerView 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:id="@+id/profile_recyclerview" 
    app:layout_behavior="@string/appbar_scrolling_view_behavior" /> 

<android.support.design.widget.FloatingActionButton 
    android:id="@+id/fab" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:visibility="gone" 
    android:layout_margin="@dimen/fab_margin" 
    app:layout_anchor="@+id/profileactivity_appbar" 
    app:layout_anchorGravity="bottom|right|end" 
    app:backgroundTint="@color/ColorPrimary" 
    android:src="@drawable/ic_create_white_48dp"/> 

<android.support.design.widget.AppBarLayout 
    android:id="@+id/profileactivity_appbar" 
    android:layout_width="match_parent" 
    android:layout_height="400dp" 
    android:visibility="gone" 
    android:theme="@style/AppTheme3.AppBarOverlay"> 

    <android.support.design.widget.CollapsingToolbarLayout 
     android:id="@+id/profileactivity_collapsing_toolbar" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     app:layout_scrollFlags="scroll|enterAlways" 
     app:statusBarScrim="@color/ColorPrimaryDark" 
     app:contentScrim="?attr/colorPrimary" 
     app:expandedTitleMarginStart="48dp" 
     app:expandedTitleMarginEnd="64dp"> 

     <ImageView 
      android:id="@+id/profileactivity_fullimage" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:scaleType="centerCrop" 
      app:layout_scrollFlags="scroll|enterAlways" 
      app:layout_collapseMode="parallax" /> 

     <android.support.v7.widget.Toolbar 
      android:id="@+id/toolbar" 
      android:layout_width="match_parent" 
      android:layout_height="?attr/actionBarSize" 
      app:layout_scrollFlags="scroll|enterAlways" 
      app:popupTheme="@style/ThemeOverlay.AppCompat.Light" 
      app:layout_collapseMode="pin" /> 

    </android.support.design.widget.CollapsingToolbarLayout> 

    </android.support.design.widget.AppBarLayout> 

</android.support.design.widget.CoordinatorLayout> 

などcontent_profile_edit.xml

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:id="@+id/profile_edit_layout" 
    android:layout_alignParentBottom="true" 
    android:visibility="gone" 
    app:layout_behavior="@string/appbar_scrolling_view_behavior"> 

<android.support.v4.widget.NestedScrollView 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:id="@+id/profile_fragment_nested" 
    android:layout_height="match_parent" 
    android:padding="10dp"> 

    <!-- other views --> 

</android.support.v4.widget.NestedScrollView> 

</RelativeLayout> 
+0

ツールバーとタブレイアウトをピンで固定する方法 –

+0

@BincyBaby私はあなたをよく理解していませんが、[cheesesquare releases](https://github.com/chrisbanes/cheesesquare/releases)をチェックすることができます –

+0

この方法は問題なく動作しますが、ツールバーとタブレイアウトを固定したいのですが、これはうまくいきません。 –

1

私はRecyclerViewとCollapsingToolbarLayoutにも問題がありました(全く崩壊しませんでした)。あなたがまだやっていないのなら、recyclerview、appcompat、designの現在のバージョン23.4。+を使ってみてください。

+0

私の問題は、問題を崩壊されていません。あなたは私がスムーズに超滑らかな画像に触れることを介してスクロールするときにビデオを見る場合。しかし、recyclerviewでスクロールすると、崩壊する画像ビューのように滑らかではありません。 –

+0

APIの最新バージョンを試しましたか?修正されたバグである可能性があります。私はあなたのレイアウトを試して、すべてうまく動作します。 – b00n12

+0

私は23.4.0バージョンにすべてを更新しました。しかし、ここでも同じ問題があります。 –

1
/** 
google solve this issue in 26 api level .I spent my whole day finally I found this answer. For Demo You create one android studio Scrolling Activity and do following changes upgrade all repository to 26 version and you will see this scrolling smoothly effect. 
**/ 

apply plugin: 'com.android.application' 

android { 
    **compileSdkVersion 26 
    buildToolsVersion "26.0.1"** 
    defaultConfig { 
     applicationId "com.example.sandeep.quantauser" 
     minSdkVersion 19 
     **targetSdkVersion 26** 
     versionCode 1 
     versionName "1.0" 
     testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 

    } 
    buildTypes { 
     release { 
      minifyEnabled false 
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 
     } 
    } 
} 

dependencies { 
    compile fileTree(include: ['*.jar'], dir: 'libs') 
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { 
     exclude group: 'com.android.support', module: 'support-annotations' 
    }) 
    compile files('libs/ksoap2-android-assembly-3.0.0-jar-with-dependencies.jar') 
    compile files('libs/apache-jakarta-commons-net-1.4.1.jar') 
    compile 'com.theartofdev.edmodo:android-image-cropper:2.4.+' 
    compile 'com.github.bumptech.glide:glide:3.7.0' 
    testCompile 'junit:junit:4.12' 
    compile files('libs/itextpdf-5.4.0.jar') 
    **compile "com.android.support:support-core-utils:26.0.2" 
    compile 'com.android.support:design:26.0.2' 
    compile 'com.android.support:appcompat-v7:26.0.2' 
    compile 'com.android.support:cardview-v7:26.0.2'** 
} 

**allprojects { 
    repositories { 
     jcenter() 
     maven { 
      url "https://maven.google.com" 
     } 
    } 
}** 
関連する問題