1,直接回到顶部

recyview.getLinearLayoutManager().scrollToPositionWithOffset(0, 0);

2,慢慢的回到顶部

private void goTop(int currentPoint) {
        if (currentPoint >= 0) {
            int step = 3;
            if (currentPoint % 10 > 1)
                step = 10;
            if (currentPoint % 5 > 1)
                step = 5;
            if (currentPoint - step > 0) {
                getView().getLinearLayoutManager().scrollToPositionWithOffset(currentPoint - step, 0);
            } else {
                getView().getLinearLayoutManager().scrollToPositionWithOffset(0, 0);
                return;
            }
            Message msg = Message.obtain();
            msg.obj = currentPoint - step;
            msg.what = WHAT_DELAYED_GO_TOP;
            goTopHandler.sendMessageDelayed(msg, 30);
        }
    }

private static int WHAT_DELAYED_GO_TOP = 212;

/**
     * 解决内存泄漏问题
     */
    private final static class GoTopHandler extends Handler {
        private SoftReference<IndexForumContentPresenter> softReference;

private GoTopHandler(IndexForumContentPresenter indexFragmentPresenter) {
            this.softReference = new SoftReference<>(indexFragmentPresenter);
        }

@Override
        public void handleMessage(Message msg) {
            // 作废重复调用
            if (this.softReference.get() == null)
                return;
            if (msg.what == WHAT_DELAYED_GO_TOP) { // 切换轮播
                // 回调给界面进行切换界面操作
                this.softReference.get().goTop((Integer) msg.obj);
            }
        }
    }
2.1慢慢的回到顶部:调用

int firstPosition = recyview.getLinearLayoutManager().findFirstVisibleItemPosition();
goTop(firstPosition);

Android RecyView 滑动置指定位置的更多相关文章

  1. RecyclerView滑动到指定位置,并置顶

    一般我们用 mRecycleview.smoothScrollToPosition(0)滑动到顶部,具有滚动效果,但是如果我们想滚动到任意指定位置,那么smoothScrollToPosition() ...

  2. Android 在图片的指定位置添加标记

    这些天,项目里加了一个功能效果,场景是: 假如有一个家居图片,图片里,有各样的家居用品: 桌子,毛巾,花瓶等等,需要在指定的商品处添加标记,方便用户直接看到商品,点击该标记,可以进入到商品详情页 .实 ...

  3. jquery实现点击按钮滑动到指定位置

    <body> <script type="text/javascript"> function click_scroll() { var scroll_of ...

  4. android学习——popupWindow 在指定位置上的显示

    先看效果图,免得浪费大家时间,看是不是想要的效果 . 直接上代码 ,核心方法. [java] view plaincopy private void showPopupWindow(View pare ...

  5. 鼠标滑动到指定位置时div固定在头部

    $(function(){ $(window).scroll(function () {            if ($(window).scrollTop() > 253) {       ...

  6. JQuery滑动到指定位置

    $('html, body').animate({ scrollTop: next_tip.offset().top + "px"},500);

  7. 横向滑动的HorizontalListView滑动指定位置的解决方法

    项目中用到了自定义横向滑动的控件:HorizontalListView,点击其中一项,跳转到另外一个大图界面,大图界面也是HorizontalListView,想使用setSelection方法设定 ...

  8. (转载) popupWindow 指定位置上的显示

    popupWindow 指定位置上的显示 标签: androidpopupWindowpopupWindow具体位置放置 2014-07-09 16:23 1114人阅读 评论(0) 收藏 举报  分 ...

  9. jQuery实现将div中滚动条滚动到指定位置的方法

    1.JS代码: onload = function () { //初始化 scrollToLocation(); }; function scrollToLocation() { var mainCo ...

随机推荐

  1. JAVA基础知识总结10(包类)

    包:定义包用package关键字. 1:对类文件进行分类管理. 2:给类文件提供多层名称空间. 如果生成的包不在当前目录下,需要最好执行classpath,将包所在父目录定义到classpath变量中 ...

  2. android手势(gesture)

    需要实现两个接口,OnTouchListener ,OnGestureListener 在接口方法中实现各种事件 详见:http://www.cnblogs.com/JczmDeveloper/p/3 ...

  3. Codeforces 1136F Cooperative Game (神仙题)

    这种题就是难者不会,会者不难. 博客讲的很详细了 代码: #include <bits/stdc++.h> using namespace std; string s; int read( ...

  4. win10 更换秘钥报错:拒绝访问:所请求的操作需要提升特权

    直接打开cmd执行换秘钥的命令: slmgr /ipk VK7JG-NPHTM-C97JM-9MPGT-3V66T slmgr /skms kms.xspace.in slmgr /ato 报错如图: ...

  5. mysql 5.7.11 源码安装

    mysql5.711安装 1.安装boost包下载地址http://sourceforge.net/projects/boost/files/boost/ 2.解压boost_1_59_0.tar.g ...

  6. ROS Learning-029 (提高篇-007 A Mobile Base-05) 控制移动平台 --- (Python编程)控制虚拟机器人的移动(精确的制定目标位置)

    ROS 提高篇 之 A Mobile Base-05 - 控制移动平台 - (Python编程)控制虚拟机器人的移动(精确的制定目标位置) 使用 odometry 消息类型 重写 out_and_ba ...

  7. C语言-郝斌笔记-006排序及查找

    1. int partion(int *a, int low, int high) { int value = a[low]; int t; while (low < high) { while ...

  8. 长城防火墙(GFW)

    一.简介 中国防火长城,官方名为金盾工程,是由政府运作的一个互联网审查监控项目.在其管辖互联网内部建立的多套网络审查系统的总称,包括相关行政审查系统.其英文名称Great Firewall of Ch ...

  9. C++二进制文件读写

    简单二进制文件读写,多文件 /*Demo9.1.cpp*/ #include <iostream> #include <fstream> #include <string ...

  10. Cyber-Ark spring mvc @autowired

    我们帮助中国平安改进他们重要系统的特权帐号密码管理,提供给他们一个“统一的,集中的,安全的”特权帐号密码管理解决方案.完全满足平安信息安全部对“特权帐号生命周期管理”的理解和需求,而且关键组件的高可用 ...