Android RecyView 滑动置指定位置
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 滑动置指定位置的更多相关文章
- RecyclerView滑动到指定位置,并置顶
一般我们用 mRecycleview.smoothScrollToPosition(0)滑动到顶部,具有滚动效果,但是如果我们想滚动到任意指定位置,那么smoothScrollToPosition() ...
- Android 在图片的指定位置添加标记
这些天,项目里加了一个功能效果,场景是: 假如有一个家居图片,图片里,有各样的家居用品: 桌子,毛巾,花瓶等等,需要在指定的商品处添加标记,方便用户直接看到商品,点击该标记,可以进入到商品详情页 .实 ...
- jquery实现点击按钮滑动到指定位置
<body> <script type="text/javascript"> function click_scroll() { var scroll_of ...
- android学习——popupWindow 在指定位置上的显示
先看效果图,免得浪费大家时间,看是不是想要的效果 . 直接上代码 ,核心方法. [java] view plaincopy private void showPopupWindow(View pare ...
- 鼠标滑动到指定位置时div固定在头部
$(function(){ $(window).scroll(function () { if ($(window).scrollTop() > 253) { ...
- JQuery滑动到指定位置
$('html, body').animate({ scrollTop: next_tip.offset().top + "px"},500);
- 横向滑动的HorizontalListView滑动指定位置的解决方法
项目中用到了自定义横向滑动的控件:HorizontalListView,点击其中一项,跳转到另外一个大图界面,大图界面也是HorizontalListView,想使用setSelection方法设定 ...
- (转载) popupWindow 指定位置上的显示
popupWindow 指定位置上的显示 标签: androidpopupWindowpopupWindow具体位置放置 2014-07-09 16:23 1114人阅读 评论(0) 收藏 举报 分 ...
- jQuery实现将div中滚动条滚动到指定位置的方法
1.JS代码: onload = function () { //初始化 scrollToLocation(); }; function scrollToLocation() { var mainCo ...
随机推荐
- springboot中单元测试
测试service: 测试api:
- C++的继承与接口
1.继承方式 三种继承方式,public,private,protected.注意,继承方式是相对于某一层类的方法而言,并不是相对于子类的对象而言.对于外部世界()对象来说,protected和pri ...
- NLTK词性标注解释
1. CC Coordinating conjunction 连接词2. CD Cardinal number 基数词3. DT Determin ...
- Opencv Laplacian(拉普拉斯算子)
#include <iostream>#include <opencv2/opencv.hpp>#include <math.h> using namespace ...
- VMware Workstation 软件 创建 Ubuntu 14.04虚拟机
VMware Workstation 软件 创建 Ubuntu 14.04虚拟机 1. 安装VMare Workstation 软件 下载VMware 11 软件 http://www.dntk.or ...
- c++ 切勿重新定义继承来的带缺省参数的函数
切勿重新定义继承来的带缺省参数的函数.我们知道,继承来的函数是virtual 的,至于原因在上一节中已经说明了,即“切勿重新定义父类non-virtual函数”.所以确切的描述应该是“切勿重新定义继承 ...
- 异常日志记录 DDLog
项目中如果想把异常捕获再写入文件,有个十分容易使用的库DDLog. 首先导入库,在git上下载. 一:在项目初始化指定全局LogLeve ,一般在xxxapp.m中 staticconstint dd ...
- bzoj2134 错选单位
传送门 题目 Input n很大,为了避免读入耗时太多, 输入文件只有5个整数参数n, A, B, C, a1, 由上交的程序产生数列a. 下面给出pascal/C/C++的读入语句和产生序列的语句( ...
- EMR问题
-- 门急诊患者生命体征信息 select t.clinic_code, t.*,t.rowid from ptm_opr_maininfo t where t.patient_id='0000E05 ...
- 《Effective Java》第2章 创建和销毁对象
第2条:遇到多个构造器参数时要考虑用构建器 与构造器相比,builder的微略优势在于,builder可以有多个可变(varargs)参数.构造器就像方法一样,只能有一个可变参数.因为builder利 ...