当前位置:网站首页>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
边栏推荐
- 开关电源设计分享及电源设计技巧图解
- Getting started with vcpkg
- On the forced conversion of C language pointer
- ESP32 LVGL8. 1 - calendar (calendar 25)
- Feature selection feature_ selection--SelectKBest
- Class loading process of JVM
- Screen right-click menu in souI
- Methods of nested recycleview to solve sliding conflict and incomplete item display
- Quick start to static class variables
- Get a list of recent apps
猜你喜欢
Introduction to ROS learning notes (II)
ESP32 LVGL8. 1 - textarea text area (textarea 26)
ESP32 LVGL8. 1 - checkbox (checkbox 23)
c#:泛型反射
ESP32 LVGL8. 1. Detailed migration tutorial of m5stack + lvgl + IDF (27)
Practice of Druid SQL and security in meituan review
2022.04.23 (lc_763_divided into letter interval)
剑指 Offer II 116. 省份数量-空间复杂度O(n),时间复杂度O(n)
The fifth bullet of MySQL learning -- detailed explanation of transaction and its operation characteristics
【历史上的今天】4 月 23 日:YouTube 上传第一个视频;网易云音乐正式上线;数字音频播放器的发明者出生
随机推荐
The type initializer for ‘Gdip‘ threw an exception
[advanced level 11 of C language -- character and string functions and their simulation implementation (2)]
Redis optimization series (III) solve common problems after master-slave configuration
网络协议之:sctp流控制传输协议
Simple use of navigation in jetpack
中金财富怎么样?在上边开户安全吗
Tencent map and high logo removal method
Use of content provider
Zlib realizes streaming decompression
Practice of Druid SQL and security in meituan review
C1000k TCP connection upper limit test 1
Nacos cluster construction and MySQL persistence configuration
SSDB Foundation
Click the input box to pop up the keyboard layout and move up
SSDB foundation 2
MySQL Téléchargement et installation de la version Linux
高层次人才一站式服务平台开发 人才综合服务平台系统
7、 DOM (Part 2) - chapter after class exercises and answers
Nacos as service registry
Raspberry pie 18b20 temperature