hackyviewpager有什么用
继承于viewpager 可以和photoView一起使用,实现相册图片的左右滑动,放大缩小,等
package davidwang.tm.view; import android.content.Context;
import android.support.v4.view.ViewPager;
import android.util.AttributeSet;
import android.view.MotionEvent; /**
* Found at http://stackoverflow.com/questions/7814017/is-it-possible-to-disable-scrolling-on-a-viewpager.
* Convenient way to temporarily disable ViewPager navigation while interacting with ImageView.
*
* Julia Zudikova
*/ /**
* Hacky fix for Issue #4 and
* http://code.google.com/p/android/issues/detail?id=18990
* <p/>
* ScaleGestureDetector seems to mess up the touch events, which means that
* ViewGroups which make use of onInterceptTouchEvent throw a lot of
* IllegalArgumentException: pointerIndex out of range.
* <p/>
* There's not much I can do in my code for now, but we can mask the result by
* just catching the problem and ignoring it.
*
* @author Chris Banes
*/
public class HackyViewPager extends ViewPager { private boolean isLocked; public HackyViewPager(Context context) {
super(context);
isLocked = false;
} public HackyViewPager(Context context, AttributeSet attrs) {
super(context, attrs);
isLocked = false;
} @Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
if (!isLocked) {
try {
return super.onInterceptTouchEvent(ev);
} catch (IllegalArgumentException e) {
e.printStackTrace();
return false;
}
}
return false;
} @Override
public boolean onTouchEvent(MotionEvent event) {
if (!isLocked) {
return super.onTouchEvent(event);
}
return false;
} public void toggleLock() {
isLocked = !isLocked;
} public void setLocked(boolean isLocked) {
this.isLocked = isLocked;
} public boolean isLocked() {
return isLocked;
} }
hackyviewpager有什么用的更多相关文章
- 仿微信朋友圈图片查看-glide加载网络图片,photoview 实现缩放
http://www.cnblogs.com/csonezp/p/5083286.html 这里实现的效果就和微信朋友圈点击图片后查看大图一样,如果你不清楚是什么效果,可以拿出手机,打开朋友圈,找到一 ...
- Android 高仿微信朋友圈动态, 支持双击手势放大并滑动查看图片。
转载请注明出处:http://blog.csdn.net/sk719887916/article/details/40348873 作者skay: 最近参与了开发一款旅行APP,其中包含实时聊天和动态 ...
- 用开源项目PhotoView实现图片的双指缩放和双击放大缩小
项目地址:https://github.com/chrisbanes/PhotoView 用开源项目有个好处,一是实现简单,二是bug少.那么我们就来说下这个项目能够实现的效果: 1.单个图片的双指缩 ...
- Android 仿微信朋友圈查看
项目要做一个类似于这样的功能,就做了. 项目下载地址:http://download.csdn.net/detail/u014608640/9917626 一,看下效果: 二.activity类 pu ...
- 点击查看大图Activity
1.使用方式 Intent intent = new Intent(FriendCircleActivity.this, ImageGralleryPagerActivity.class);//0,索 ...
- Android仿微信朋友圈图片查看器
转载请注明出处:http://blog.csdn.net/allen315410/article/details/40264551 看博文之前,希望大家先打开自己的微信点到朋友圈中去,细致观察是不是发 ...
随机推荐
- Page Cache, the Affair Between Memory and Files
Previously we looked at how the kernel manages virtual memory for a user process, but files and I/O ...
- 前端笔试题 JS部分
题目 http://www.itmian4.com/forum.php?mod=viewthread&tid=4540 http://www.itmian4.com/forum.php?mod ...
- 帝国cms7.2灵动标签万能教程
学完本文,就完全能掌握帝国模板开发制作啦!这里只介绍sql语句调用方法(方便,快捷!) 灵动标签语法: [e:loop={,24,0}] 模板内容 [/e:loop] 详细解释:黄色部分:条件语句,即 ...
- Windows10笔记本双显卡导致的启动黑屏解决办法之一
参考链接:http://www.zhihu.com/question/33662311 大概就是关掉ulps. ulps,显卡的多核心超低功率状态,节能用的,AMD出的双显卡的一种节能方案.不过,与某 ...
- HDU 2104 hide handkerchief
题解:由题目可以知道,如果n和m的最大公约数不为1,那么总有箱子是无法遍历的,所以求一遍GCD就可以判断了. 注意点:一定要记住判断是==,在做题时又忘了. #include <cstdio&g ...
- python Unicode转ascii码的一种方法
缘起 看到这样的数据:Marek Čech.Beniardá怎样变成相对应的ascii码呢 解决 import unicodedata s = u"Marek Čech" #(u表 ...
- 在一个数组中是否存在两个数A、B的和为M
#include <iostream>#include <algorithm>//#include <vector>using namespace std; int ...
- JavaSE学习总结第15天_集合框架1
15.01 对象数组的概述和使用 public class Student { // 成员变量 private String name; private int age; // 构造方法 publ ...
- Oracle语句优化规则(二)
21. 用EXISTS替换DISTINCT 当提交一个包含一对多表信息(比如部门表和雇员表)的查询时,避免在SELECT子句中使用DISTINCT. 一般可以考虑用EXIST替换 例如: ...
- Agile methodology
ntroduction Waterfall model follows application development in phases with checkpoint and deliverabl ...