android - Recyclerview 上的加速滚动

标签 android android-layout android-studio scrollbar android-recyclerview

我有一个包含 CardsView 列表的 RecycleView。 RecycleView 在 NestedScrollView 中,因为我有一个可折叠的标题。 滚动没有加速,当我从屏幕上移开手指时它停止滚动,我想要加速滚动。

这些是我的布局。

<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:layout_height="match_parent"
    app:layout_behavior="@string/appbar_scrolling_view_behavior"
    tools:context=".articles.ArticlesActivity"
    tools:showIn="@layout/activity_articles"
    >


    <android.support.v7.widget.RecyclerView
        android:id="@+id/articles_lista"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:fadeScrollbars="true"
        android:scrollbars="vertical"
        />

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

我的 CardView 布局容器。

<android.support.v7.widget.CardView xmlns:card_view="http://schemas.android.com/apk/res-auto"
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/articles_card"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    card_view:cardCornerRadius="6dp"
    card_view:cardUseCompatPadding="true"
    card_view:cardPreventCornerOverlap="true"
    android:layout_marginTop="0dp"
    android:layout_marginBottom="0dp"
    android:layout_marginLeft="10dp"
    android:layout_marginRight="10dp"
    card_view:cardElevation="5dp"

    android:overScrollMode="always"
    android:fadeScrollbars="true">

    <LinearLayout
        android:orientation="vertical"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:padding="10dp"
            android:id="@+id/article_card_title"
            android:textAppearance="?android:attr/textAppearanceLarge"
            android:textColor="#000"/>

    </LinearLayout>

</android.support.v7.widget.CardView>

和JAVA代码:

        RecyclerView recyclerView = (RecyclerView)findViewById(R.id.articles_lista);
        LinearLayoutManager layoutManager = new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false);
        recyclerView.setLayoutManager(layoutManager);
        ArticlesAdapter adapter = new ArticlesAdapter(Mock.getNoticias(1L), this);
        recyclerView.setAdapter(adapter);

谢谢。

编辑:

我的新布局正在运行,看起来像:

<RelativeLayout 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:layout_height="match_parent"
    app:layout_behavior="@string/appbar_scrolling_view_behavior"
    tools:context="newser.sab.com.newser.articles.ArticlesActivity2"
    tools:showIn="@layout/app_bar_articles2">

    <android.support.v7.widget.RecyclerView
        android:id="@+id/articles_lista"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:fadeScrollbars="true"
        android:scrollbars="vertical"
        />

</RelativeLayout>

最佳答案

正在更改布局:

<RelativeLayout 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:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context="newser.sab.com.newser.articles.ArticlesActivity2"
tools:showIn="@layout/app_bar_articles2">

<android.support.v7.widget.RecyclerView
    android:id="@+id/articles_lista"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fadeScrollbars="true"
    android:scrollbars="vertical"
    />

关于android - Recyclerview 上的加速滚动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36522320/

相关文章:

android - 非常简单的代码,但是使用 Fragment 时出现错误 "Activity has been destroyed"

android - 生成带混淆的签名 apk 时应用程序崩溃 (NoSuchMethodError)

android - 华为 P40 Pro (ELS-NX9) 上的 INSTALL_FAILED_ABORTED 错误

android - 在 Android 中命名资源最清晰的方法是什么?

android - 如何开发/移植原生 C 库到 android?

android - Android Studio 中使用 kotlin 的未解决引用 currentThread().wait()

Android 无法删除自定义标题栏周围的填充

android - 选项卡不显示

android - Findbugs 失败并显示 "java.io.IOException: No files to analyze could be opened"

java - 如何搜索包含特定动态值的列表