当前位置:网站首页>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
边栏推荐
- 该买什么设备,Keysight 给你挑好了
- Scrollto and scrollby
- ESP32 LVGL8. 1 - input devices (input devices 18)
- mysql_linux版本的下载及安装详解
- [record] typeerror: this getOptions is not a function
- ESP32 LVGL8. 1 - bar progress bar (bar 21)
- Screen right-click menu in souI
- ESP32 LVGL8. 1 - msgbox message box (msgbox 28)
- Is it safe to open an account in Bohai futures.
- Summary of actual business optimization scheme - main directory - continuous update
猜你喜欢
ESP32 LVGL8. 1 - roller rolling (roller 24)
12 examples to consolidate promise Foundation
The difference between ordinary inner class and static inner class
Introduction to ROS learning notes (II)
mysql_linux版本的下載及安裝詳解
ESP32 LVGL8. 1. Detailed migration tutorial of m5stack + lvgl + IDF (27)
剑指 Offer II 116. 省份数量-空间复杂度O(n),时间复杂度O(n)
Using Visual Studio code to develop Arduino
Wechat video extraction and receiving file path
MySQL restores or rolls back data through binlog
随机推荐
Sentinel服务熔断实战(sentinel整合ribbon+openFeign+fallback)
MySQL restores or rolls back data through binlog
Download xshell 6 and xftp6 official websites
The corresponding permissions required to automatically open the app in the setting interface through accessibility service
SSDB foundation 1
SSDB基础
[today in history] April 23: the first video uploaded on YouTube; Netease cloud music officially launched; The inventor of digital audio player was born
Fundamentals of machine learning theory -- some terms about machine learning
Dynamically add and delete layouts
Tencent cloud GPU best practices - remote development training using jupyter pycharm
Xlslib use
ESP32 LVGL8. 1 - input devices (input devices 18)
Introduction to ROS learning notes (II)
Sword finger offer II 116 Number of provinces - spatial complexity O (n), time complexity O (n)
ESP32 LVGL8. 1 - bar progress bar (bar 21)
Seata handles distributed transactions
MySQL statement
One stop service platform for high-level talents and development of comprehensive service platform system for talents
腾讯云GPU最佳实践-使用jupyter pycharm远程开发训练
Esp32 (UART 485 communication) - 485 communication of serial port (3)