当前位置:网站首页>RecyclerView滚动到指定位置
RecyclerView滚动到指定位置
2022-06-25 11:48:00 【用户9854323】
1、mLayoutManager
private void moveToPosition(int position) {
if (position >= 0) {
mLayoutManager.scrollToPositionWithOffset(3, 0);
}
}2、LinearSmoothScroller
mTopSmoothScroller = new TopSmoothScroller(getActivity());
private void smoothScroll(int position) {
mRecyclerView.postDelayed(new Runnable() {
@Override
public void run() {
if (!isDetached() && position >= 0 && getActivity() != null && mTopSmoothScroller != null) {
mTopSmoothScroller.setTargetPosition(position);
mLayoutManager.startSmoothScroll(mTopSmoothScroller);
}
}
}, 0);
}TopSmoothScroller:
public class TopSmoothScroller extends LinearSmoothScroller {
public TopSmoothScroller(Context context) {
super(context);
}
@Override
protected int getHorizontalSnapPreference() {
return SNAP_TO_START;//具体见源码注释
}
@Override
protected int getVerticalSnapPreference() {
return SNAP_TO_START;//具体见源码注释
}
}3、RecyclerView的
scrollBy(int x, int y)
scrollToPosition(int position)边栏推荐
- Where do the guests come from
- ThingsPanel 發布物聯網手機客戶端(多圖)
- Nacos installation and use
- Manually rollback abnormal data
- JS indexof() always returns -1
- Source code analysis of AQS & reentrantlock
- Is the online stock trading account opening ID card information safe?
- TCP如何处理三次握手和四次挥手期间的异常
- Actual combat summary of Youpin e-commerce 3.0 micro Service Mall project
- Spark history server and event log details
猜你喜欢

VFP develops a official account to receive coupons, and users will jump to various target pages after registration, and a set of standard processes will be sent to you

VFP uses Kodak controls to control the scanner to solve the problem that the volume of exported files is too large

What should I do to dynamically add a column and button to the gird of VFP?

Real software developers will use this method to predict the future

Specific meanings of node and edge in Flink graph

RPC typical framework

Old ou, a fox friend, has had a headache all day. The VFP format is always wrong when it is converted to JSON format. It is actually caused by disordered code

What are redis avalanche, penetration and breakdown?

黑马畅购商城---8.微服务网关Gateway和Jwt令牌

Windows11 MySQL service is missing
随机推荐
Uncover gaussdb (for redis): comprehensive comparison of CODIS
Tool usage summary
Actual combat summary of Youpin e-commerce 3.0 micro Service Mall project
Hangzhou / Beijing neitui Ali Dharma academy recruits academic interns in visual generation (talent plan)
Flink deeply understands the graph generation process (source code interpretation)
Design and implementation of university laboratory goods management information system based on SSH
What should I do to dynamically add a column and button to the gird of VFP?
VFP a picture processing library, simple and easy to use, free of charge, worth recommending
Builder pattern
How terrible is it not to use error handling in VFP?
try-catch-finally
WebRTC Native M96 基础Base模块介绍之网络相关的封装
PD1.4转HDMI2.0转接线拆解。
Spark Tuning common configuration parameters
Using DBF of VFP to web salary query system
Whole process of web page request
Why can't the form be closed? The magic of revealing VFP object references
VFP uses Kodak controls to control the scanner to solve the problem that the volume of exported files is too large
Nacos installation and use
WebRTC Native M96 基础Base模块介绍之实用方法的封装(MD5、Base64、时间、随机数)