Skip to content

Commit eba3ee0

Browse files
authored
Update README.md
1 parent 7ba5aab commit eba3ee0

File tree

1 file changed

+132
-1
lines changed

1 file changed

+132
-1
lines changed

README.md

+132-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,133 @@
11
# ZoomHelper
2-
ZoomHelper
2+
ZoomHelper will make any view to be zoomable just like the Instagram pinch-to-zoom. :wink:
3+
4+
![ZoomHelper (RecyclerViewSample)](Previews/ZoomHelper_rv.gif)
5+
6+
## Installation
7+
8+
ZoomHelper is available in the JCenter, so you just need to add it as a dependency
9+
10+
Gradle
11+
```gradle
12+
implementation 'com.aghajari.zoomhelper:ZoomHelper:1.0.1'
13+
```
14+
15+
Maven
16+
```maven
17+
<dependency>
18+
<groupId>com.aghajari.zoomhelper</groupId>
19+
<artifactId>ZoomHelper</artifactId>
20+
<version>1.0.1</version>
21+
<type>pom</type>
22+
</dependency>
23+
```
24+
25+
## Usage
26+
27+
just override dispatchTouchEvent in your Activity and pass all touch events to ZoomHelper!
28+
```kotlin
29+
30+
override fun dispatchTouchEvent(ev: MotionEvent?): Boolean {
31+
return ZoomHelper.getInstance().dispatchTouchEvent(ev!!,this) || super.dispatchTouchEvent(ev)
32+
}
33+
34+
```
35+
36+
And set View to be zoomable :
37+
```kotlin
38+
39+
ZoomHelper.addZoomableView(view)
40+
// ZoomHelper.addZoomableView(view,tag)
41+
42+
```
43+
44+
Or make a zoomable View by using xml layout :
45+
```xml
46+
<ImageView
47+
android:id="@+id/imageView"
48+
android:layout_width="wrap_content"
49+
android:layout_height="wrap_content">
50+
51+
<tag android:id="@+id/zoomable" android:value="ZoomableViewTag" />
52+
</ImageView>
53+
```
54+
55+
And we are Done! :smiley:
56+
57+
## Customization
58+
```kotlin
59+
ZoomHelper.getInstance().minScale = 1f
60+
ZoomHelper.getInstance().maxScale = Float.MAX_VALUE
61+
ZoomHelper.getInstance().shadowColor = Color.BLACK
62+
ZoomHelper.getInstance().maxShadowAlpha = 0.6f
63+
ZoomHelper.getInstance().shadowAlphaFactory = 4
64+
ZoomHelper.getInstance().dismissDuration = 200
65+
ZoomHelper.getInstance().layoutTheme = android.R.style.Theme_Translucent_NoTitleBar_Fullscreen
66+
ZoomHelper.getInstance().isEnabled = true
67+
```
68+
69+
![ZoomHelper (Simple)](Previews/ZoomHelper-simple.gif) ![ZoomHelper (Custom)](Previews/ZoomHelper-custom.gif)
70+
71+
you can disable a zoomable view by using this code :
72+
```kotlin
73+
ZoomHelper.removeZoomableView(view)
74+
```
75+
Or skip a View or a ViewGroup and all its children :
76+
```kotlin
77+
ZoomHelper.skipLayout(view,true)
78+
```
79+
And also you can disable ZoomHelper by using this code :
80+
```kotlin
81+
ZoomHelper.getInstance().isEnabled = false
82+
```
83+
Check the layout is zooming currently :
84+
```kotlin
85+
if (ZoomHelper.getInstance().isZooming)
86+
```
87+
88+
### Listeners :
89+
You can add callbacks to listen for specific events.
90+
91+
```kotlin
92+
ZoomHelper.getInstance().addOnZoomStateChangedListener(object : ZoomHelper.OnZoomStateChangedListener{
93+
override fun onZoomStateChanged(zoomHelper: ZoomHelper, zoomableView: View, isZooming: Boolean) {
94+
Toast.makeText(zoomableView.context,if (isZooming) "Zooming started" else "Zooming ended", Toast.LENGTH_SHORT).show()
95+
// you can also get zoomableView Tag
96+
val tag = ZoomHelper.getZoomableViewTag(zoomableView)
97+
}
98+
})
99+
100+
ZoomHelper.getInstance().addOnZoomScaleChangedListener(object : ZoomHelper.OnZoomScaleChangedListener{
101+
override fun onZoomScaleChanged(zoomHelper: ZoomHelper, zoomableView: View, scale: Float, event: MotionEvent?) {
102+
// called when zoom scale changed
103+
}
104+
})
105+
106+
ZoomHelper.getInstance().addOnZoomLayoutCreatorListener(object : ZoomHelper.OnZoomLayoutCreatorListener{
107+
override fun onZoomLayoutCreated(zoomHelper: ZoomHelper, zoomableView: View, zoomLayout: FrameLayout) {
108+
// called when zoomlayout created (zoom started)
109+
}
110+
})
111+
```
112+
Also the default view listeners (onClick,onLongClick,onTouch) will work as well!
113+
114+
## Author
115+
Amir Hossein Aghajari
116+
117+
Inspired by [ImageZoomHelper](https://github.com/okaybroda/ImageZoom) library.
118+
119+
License
120+
=======
121+
122+
Copyright 2020 Amir Hossein Aghajari
123+
Licensed under the Apache License, Version 2.0 (the "License");
124+
you may not use this file except in compliance with the License.
125+
You may obtain a copy of the License at
126+
127+
http://www.apache.org/licenses/LICENSE-2.0
128+
129+
Unless required by applicable law or agreed to in writing, software
130+
distributed under the License is distributed on an "AS IS" BASIS,
131+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
132+
See the License for the specific language governing permissions and
133+
limitations under the License.

0 commit comments

Comments
 (0)