相关疑难解决方法(0)

如何使RecyclerView顺利滚动?

这更像是一个通用的问题,但经过大量的搜索和尝试,我无法理解为什么这么难实现.是我能找到的最接近的答案,但仍然无法实现.

具体来说,我正在使用RecyclerView和GridLayoutManager.我想要的是平滑滚动的网格布局(如默认的gallary应用程序),没什么特别的,但网格布局管理器的默认实现以"生涩"的方式滚动视图.我试图从上面的链接实现该方法,但没有成功.

我也尝试实现LinearSmoothScroller,但我不确定如何实现computeScrollVectorForPosition方法.关于computeScrollVectorForPosition的Google文档字面上有0个字.

我找到了这个3部分的教程,但它没什么帮助.所以,我想问的是:我们可以在LinearSmoothScroller中实现某种模板代码,还是扩展RecyclerView.SmoothScroller并实现平滑滚动?即使代码依赖于gridlayout中每行的项目数和项目数,也必须有一些方法可以轻松完成.我在这里错过了什么吗?

android smooth-scrolling gridlayoutmanager android-recyclerview

24
推荐指数
5
解决办法
3万
查看次数

区分Recyclerview中的Drag动作和Fling动作

Recyclerview现在有3个州.

SCROLL_STATE_IDLE, SCROLL_STATE_DRAGGING, SCROLL_STATE_SETTLING

为此提出的一个问题包括一个投掷状态.我无法确定是否有任何关于此的事情.

有没有办法区分Recyclerview中的Drag和Fling.

编辑:对此类功能的要求:当用户浏览时,我希望能够在回收器视图中暂停加载图像(所有图像都是URL请求)并在他到达感兴趣的项目后恢复,从而确保他是图像目前在其他人之前查看负载.

android android-recyclerview

15
推荐指数
2
解决办法
4158
查看次数

获取RecyclerView或Webview的滚动Y.

我已经创建了一个活动Webview内容Recyclerview.我想在滚动webview时获得滚动Y位置.我试过Webview.getScrollY(),Webview.getY(),RecyclerView.getScrollY(),RecyclerView.getY(),...但它不工作的罚款.我无法获得当前滚动Y.是否有任何建议获得滚动Y WebviewRecyclerView

android android-webview android-recyclerview

9
推荐指数
2
解决办法
1万
查看次数

为什么在 RecyclerView 项中 ConstraintLayout 比 LinearLayout 慢?

我正在将 recyclyerView 的 xml 项从 LinearLayout 更改为 ConstraintLayout。当我水平滚动 recyclerView 时,它比 LinearLayout 滞后并且呈现得非常慢。

约束布局

约束布局

线性布局

线性布局

在这里,我将分享我的 ConstraintLayout xml。

我的 ConstraintLayout 项目

<android.support.v7.widget.CardView 
    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="85dp"
    android:layout_height="wrap_content">

<android.support.constraint.ConstraintLayout
    android:id="@+id/merchant_layout"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginBottom="10dp"
    android:layout_marginEnd="5dp"
    android:layout_marginStart="5dp">

    <de.hdodenhof.circleimageview.CircleImageView
        android:id="@+id/merchant_img"
        android:layout_width="75dp"
        android:layout_height="75dp"
        android:transitionName="profile"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        tools:ignore="UnusedAttribute"
        tools:src="@drawable/avatar" />

    <com.max.xclusivekotlin.customViews.MyTextView
        android:id="@+id/merchant_name"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_marginEnd="5dp"
        android:layout_marginStart="5dp"
        android:layout_marginTop="5dp"
        android:ellipsize="end"
        android:maxLines="1"
        android:maxWidth="72dp"
        android:minWidth="72dp"
        android:textAlignment="center"
        android:textColor="@color/blackFont"
        android:textSize="14sp"
        app:layout_constraintEnd_toEndOf="@id/merchant_img"
        app:layout_constraintStart_toStartOf="@id/merchant_img"
        app:layout_constraintTop_toBottomOf="@id/merchant_img"
        tools:text="Chili's" />

    <com.max.xclusivekotlin.customViews.MyTextView
        android:id="@+id/merchant_offer_percent"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textColor="@color/redColor"
        android:textSize="12sp"
        app:layout_constraintBottom_toTopOf="@id/tv_distance"
        app:layout_constraintEnd_toStartOf="@id/merchant_offer_type"
        app:layout_constraintStart_toStartOf="@id/merchant_name"
        app:layout_constraintTop_toBottomOf="@id/merchant_name"
        app:textBold="bold"
        tools:text="25%" />

    <com.max.xclusivekotlin.customViews.MyTextView
        android:id="@+id/merchant_offer_type"
        android:layout_width="0dp"
        android:layout_height="wrap_content" …
Run Code Online (Sandbox Code Playgroud)

android android-layout android-recyclerview android-constraintlayout

6
推荐指数
2
解决办法
3717
查看次数

Android RecyclerView:如果有很多项目,则假平滑滚动到顶部

我们RecyclerView的应用程序中有您基于标准的 Feed 屏幕。

如果我有 100 多个项目RecyclerView并按“转到顶部”快捷方式,则默认行为smoothScrollToPosition(0)是需要很长时间才能滚动到顶部

它需要多长时间几乎是可笑的 - 如果您向下滚动到顶部的速度足够快(这是一个常见的用例),则需要 10 秒的快速滚动!

我们正在寻找一种方法来“伪造”滚动到顶部,如果RecyclerView> 中的项目数SOME_THRESHOLD

我不是 iOS 人,但我们的 iOS 版本(正如开发人员告诉我的那样)似乎将这种行为融入了控件中。如果项目太多,它只会做一个超级快速的模糊滚动,这显然会伪造/省略中间的许多项目。

RecyclerView 有这样的功能吗?

我们认为做多部分的事情,我们快速跳转到该项目指数SOME_THRESHOLD调用smoothScrollToPosition(0)-你的想法-但也有缺点,大多数的我们已经想到的事情。

感谢帮助,谢谢。

android android-support-library android-recyclerview

4
推荐指数
1
解决办法
510
查看次数