当前位置:网站首页>Customize the non slidable viewpage and how to use it
Customize the non slidable viewpage and how to use it
2022-04-23 19:08:00 【Little brother】
First, customize a ViewPage.
/** * Manual control viewpager Whether it can slide left and right * Remove sliding animation * setNoScroll(boolean noScroll) * * @author ex-panyong */ public class NoScrollViewPager extends ViewPager { private boolean noScroll = false; public NoScrollViewPager(Context context, AttributeSet attrs) { super(context, attrs); } public NoScrollViewPager(Context context) { super(context); } // Set whether it can slide (false: Sliding ,true: Do not slide ) public void setNoScroll(boolean noScroll) { this.noScroll = noScroll; } @Override public void scrollTo(int x, int y) { super.scrollTo(x, y); } @Override public boolean onTouchEvent(MotionEvent arg0) { /* return false;//super.onTouchEvent(arg0); */ switch(arg0.getAction()){ } return !noScroll && super.onTouchEvent(arg0); } @Override public boolean onInterceptTouchEvent(MotionEvent arg0) { return !noScroll && super.onInterceptTouchEvent(arg0); } @Override public void setCurrentItem(int item, boolean smoothScroll) { super.setCurrentItem(item, smoothScroll); } @Override public void setCurrentItem(int item) { //false Remove scrolling effect super.setCurrentItem(item,false); } }
Usage method .
stay xml The document defines :
<com.ahbcd.app.md_swms.utils.NoScrollViewPager android:id="@+id/viewpager" android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1"> </com.ahbcd.app.md_swms.utils.NoScrollViewPager>
stay Activity Use in :
NoScrollViewPager viewpager= (NoScrollViewPager) findViewById(R.id.viewpager); viewpager.setNoScroll(true); viewpager.setAdapter(new MainFragmentAdapter(fm, fragments));
版权声明
本文为[Little brother]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204210601422729.html
边栏推荐
- SSDB foundation 2
- redis优化系列(三)解决主从配置后的常见问题
- [报告] Microsoft :Application of deep learning methods in speech enhancement
- Introduction to micro build low code zero Foundation (lesson 3)
- C1000k TCP connection upper limit test
- Disable Ctrl + Alt + Del
- Sentinel服务熔断实战(sentinel整合ribbon+openFeign+fallback)
- 腾讯云GPU最佳实践-使用jupyter pycharm远程开发训练
- Actual combat of Nacos as service configuration center
- Sword finger offer II 116 Number of provinces - spatial complexity O (n), time complexity O (n)
猜你喜欢
Raspberry pie uses root operation, and the graphical interface uses its own file manager
ESP32 LVGL8. 1 - input devices (input devices 18)
2022.04.23(LC_763_划分字母区间)
mysql通过binlog恢复或回滚数据
Introduction to ROS learning notes (I)
为何PostgreSQL即将超越SQL Server?
Client interns of a large factory share their experience face to face
ESP32 LVGL8. 1 - checkbox (checkbox 23)
ArcMap连接 arcgis server
Openharmony open source developer growth plan, looking for new open source forces that change the world!
随机推荐
MVVM model
C1000k TCP connection upper limit test
MySQL statement
简化路径(力扣71)
Tencent cloud GPU best practices - remote development training using jupyter pycharm
Introduction to micro build low code zero Foundation (lesson 3)
RPM包管理
【历史上的今天】4 月 23 日:YouTube 上传第一个视频;网易云音乐正式上线;数字音频播放器的发明者出生
Esp01s with Arduino development environment
Quick start to static class variables
剑指 Offer II 116. 省份数量-空间复杂度O(n),时间复杂度O(n)
ESP32 LVGL8. 1 - arc (arc 19)
2022.04.23 (lc_763_divided into letter interval)
Tencent map and high logo removal method
电路在线模拟
SSDB基础2
Scrollto and scrollby
[record] typeerror: this getOptions is not a function
Redis optimization series (III) solve common problems after master-slave configuration
Installation, use and problem summary of binlog2sql tool