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 ...
随机推荐
- Ros学习——C++发布器publisher和订阅器subscriber
1.编写发布器 初始化 ROS 系统 在 ROS 网络内广播我们将要在 chatter 话题上发布 std_msgs/String 类型的消息 以每秒 10 次的频率在 chatter 上发布消息 在 ...
- C++面向对象类的实例题目七
题目描述: 编写两个有意义的类,使一个类嵌套在另一个类中. 分析: 本题涉及两个类student和cdegree,前者为学生类,包含学生的学号(nubner),姓名(name)和成绩(degree), ...
- win10右击windows键没有反应解决方案(1707版本)
按Win+R打开运行,输入“regedit”打开注册表编辑器. 2.在“HKEY_CLASSES_ROOT”主键下找到“linkfile”或者".lnkfile"字符串值项,在右侧 ...
- C++使用标准库的栈和队列
转自http://blog.csdn.net/zhy_cheng/article/details/8090346 使用标准库的栈和队列时,先包含相关的头文件 #include<stack> ...
- dpdk中uio技术
总结一下dpdk的uio技术 一:什么是uio技术 UIO(Userspace I/O)是运行在用户空间的I/O技术,Linux系统中一般的驱动设备都是运行在内核空间,而在用户空间用应用程序调用即可, ...
- Git 之 github分享代码
作为一个技术人员还是脱离不了屌丝的本质,所以每天都是逛逛github,看看别人有什么好的项目,自己可以给他挑挑bug也可以提供自己的水平,但是别人不那怎么才能给别人贡献代码呢?那就是fork了.... ...
- Entity Framework Tutorial Basics(29):Stored Procedure in Entity Framework
Stored Procedure in Entity Framework: Entity Framework has the ability to automatically build native ...
- try-catch-finally 规则( 异常处理语句的语法规则 )
1) 必须在 try 之后添加 catch 或 finally 块.try 块后可同时接 catch 和 finally 块,但至少有一个块. 2) 必须遵循块顺序:若代码同时使用 catch 和 ...
- Linux操作系统下IPTables配置方法详解
如果你的IPTABLES基础知识还不了解,建议先去看看. 们来配置一个filter表的防火墙 1.查看本机关于IPTABLES的设置情况 [root@tp ~]# iptables -L -n Cha ...
- delphi 调用百度地图WEBSERVICE转换GPS坐标
百度地图的API说明 使用方法 第一步,申请密钥(ak),作为访问服务的依据: 第二步,按照请求参数说明拼写发送http请求的url,注意需使用第一步申请的ak: 第三步,接收返回的数据(json或者 ...