diff --git a/README.md b/README.md index bbffa736..8cdf4d10 100755 --- a/README.md +++ b/README.md @@ -69,10 +69,32 @@ public void onCreate(Bundle savedInstanceState) { mAttacher.update(); ``` +## Issues With ViewGroups +There are some ViewGroups (ones that utilize onInterceptTouchEvent) that throw exceptions when a PhotoView is placed within them, most notably [ViewPager](http://developer.android.com/reference/android/support/v4/view/ViewPager.html) and [DrawerLayout](https://developer.android.com/reference/android/support/v4/widget/DrawerLayout.html). This is a framework issue that has not been resolved. In order to prevent this exception (which typically occurs when you zoom out), take a look at [HackyDrawerLayout](https://github.com/chrisbanes/PhotoView/blob/master/sample/src/main/java/uk/co/senab/photoview/sample/HackyDrawerLayout.java) and you can see the solution is to simply catch the exception. Any ViewGroup which uses onInterceptTouchEvent will also need to be extended and exceptions caught. Use the [HackyDrawerLayout](https://github.com/chrisbanes/PhotoView/blob/master/sample/src/main/java/uk/co/senab/photoview/sample/HackyDrawerLayout.java) as a template of how to do so. The basic implementation is: +```java +public class HackyProblematicViewGroup extends ProblematicViewGroup { + + public HackyProblematicViewGroup(Context context) { + super(context); + } + + @Override + public boolean onInterceptTouchEvent(MotionEvent ev) { + try { + return super.onInterceptTouchEvent(ev); + } catch (IllegalArgumentException e) { + e.printStackTrace(); + return false; + } + } +} +``` + ## Pull Requests / Contribution Development happens in **develop** branch of this repository, and Pull Requests should be filled against that branch. Any Pull Request against **master** will be rejected + ## License Copyright 2011, 2012 Chris Banes