Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/186.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android RecyclerView带有折叠工具栏布局平滑滚动问题_Android_Android Recyclerview_Android Collapsingtoolbarlayout_Nestedscrollview - Fatal编程技术网

Android RecyclerView带有折叠工具栏布局平滑滚动问题

Android RecyclerView带有折叠工具栏布局平滑滚动问题,android,android-recyclerview,android-collapsingtoolbarlayout,nestedscrollview,Android,Android Recyclerview,Android Collapsingtoolbarlayout,Nestedscrollview,我想将折叠工具栏布局与回收视图一起使用,比如Whatsapp 以下是拍摄的视频: 所以,当我向上滚动时,它是好的,但当我向下滚动时,它不是平滑的。我想用RecyclerView平滑地滚动它 下面是我的profile\u activity.xml: <?xml version="1.0" encoding="utf-8"?> <android.support.design.widget.CoordinatorLayout xmlns:android="ht

我想将
折叠工具栏布局
回收视图
一起使用,比如
Whatsapp

以下是拍摄的视频:

所以,当我向上滚动时,它是好的,但当我向下滚动时,它不是平滑的。我想用
RecyclerView
平滑地滚动它

下面是我的
profile\u 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>

如何修复此问题?

我在RecyclerView和CollappingToolbarLayout(完全没有崩溃)方面也遇到了问题。如果您还没有使用recyclerview、appcompat和design的当前版本23.4.+,请尝试使用。

好的,我将解释如何解决这个问题,现在我的布局非常平滑

其实我不知道它是怎么解决的,但是

  • 我删除了所有的
    android:fitsystemwindows=“true”
    属性
  • 然后将
    app:layout\u scrollFlags=“scroll | enterally”
    属性添加到
    折叠工具栏布局
    图像视图
    工具栏
  • 并将所有元素移动到xml中my
    AppBarLayout
    之前
我的
活动\u 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>
<?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>

放下ImageView的
app:layout\u scrollFlags
,看看这是否解决了问题。我认为这些标志与app:layout\u collapseMode相矛盾,如果你尝试通过图像滚动,它会非常平滑,但我不能通过recyclerview像那样滚动。我想你知道我的问题不是崩溃的问题。如果你在我通过触摸折叠图像滚动时观看视频,它会非常平滑。但是当使用recyclerview滚动时,它不会像折叠图像视图那样平滑。你尝试过最新版本的API吗?可能是一个已经修复的bug。我试过你的布局,一切都很好。我把所有的都更新到了23.4.0版本。是的,我更新了recyclerview并更改了scrollflags。那我的问题就没有了。Thankshow以锁定工具栏和tablayout@BincyBaby我不太明白你的意思,但是你能检查一下这个方法是否有效吗,但如果我想固定工具栏和表格布局,这将不会work@Bincy宝贝,我很愿意帮助你,但你必须提供一些代码,我必须看看你现在有什么。@YasinKaçmaz一些警告:如果把晶圆放在AppBarLayout上面,layout_锚id将无法建立
<?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>
/**
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"
        }
    }
}**