Skip to content

Commit 479e884

Browse files
README.md
1 parent b5f3e6d commit 479e884

File tree

1 file changed

+50
-74
lines changed

1 file changed

+50
-74
lines changed

README.md

Lines changed: 50 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,35 @@
11
# ScratchView
22

3-
This repo is an extension to https://github.com/sharish/ScratchView
3+
This repo is build over https://github.com/sharish/ScratchView
44

55

66
Demo Screen
77
------
88

9-
| ScratchImageView | ScratchTextView |
10-
| ---------------------------- | ----------------------------- |
11-
| ![ScratchImageView][scratch_image] | ![ScratchTextView][scratch_text] |
9+
![](https://raw.githubusercontent.com/AnupKumarPanwar/ScratchView/master/Screenshots/ScratchView.gif)
1210

13-
### Custom pattern for scratch view
14-
![](https://raw.githubusercontent.com/AnupKumarPanwar/ScratchView/master/Screenshots/CustomPattern.gif)
1511

1612
### Useful Methods
1713

18-
Both the views have following three methods which are useful to reveal or determine whether revealed and listener during revealing the hidden text/image.
19-
2014
* ```isRevealed()``` - tells whether the text/image has been revealed.
2115
* ```reveal()``` - reveals the image/text if not revealed yet.
2216
* ```setRevealListener(IRevealListener)``` - a callback listener interface which gets called back when user reveals the text/image
2317
through onReveal() method.
2418

19+
2520
Usage
2621
--------
2722

28-
### ScratchImageView
23+
ScratchView acts as an overlay over other views. Scratching the view makes it transparent so that the views below it are visible. Wrap all the layers in a RelativeLayout and put ScratchView above it.
24+
2925

3026
##### XML
3127

3228
```xml
33-
<com.cooltechworks.views.ScratchImageView
34-
android:id="@+id/sample_image"
29+
<com.anupkumarpanwar.scratchview.ScratchView
30+
android:id="@+id/scratch_view"
3531
android:layout_width="300dp"
3632
android:layout_height="300dp"
37-
android:background="@android:color/white"
38-
android:src="@drawable/img_sample2"
3933
app:overlay_image="@drawable/scratch_card"
4034
app:tile_mode="CLAMP"
4135
app:overlay_width="300dp"
@@ -47,60 +41,55 @@ Usage
4741
##### JAVA
4842

4943
```java
50-
ScratchImageView scratchImageView = new ScratchImageView(this);
51-
52-
scratchImageView.setRevealListener(new ScratchImageView.IRevealListener() {
53-
@Override
54-
public void onRevealed(ScratchImageView tv) {
55-
// on reveal
56-
}
57-
58-
@Override
59-
public void onRevealPercentChangedListener(ScratchImageView siv, float percent) {
60-
// on image percent reveal
61-
}
62-
});
44+
ScratchView scratchView = findViewById(R.id.scratch_view);
45+
scratchView.setRevealListener(new ScratchView.IRevealListener() {
46+
@Override
47+
public void onRevealed(ScratchView scratchView) {
48+
Toast.makeText(getApplicationContext(), "Reveled", Toast.LENGTH_LONG).show();;
49+
}
50+
51+
@Override
52+
public void onRevealPercentChangedListener(ScratchView scratchView, float percent) {
53+
if (percent>=0.5) {
54+
Log.d("Reveal Percentage", "onRevealPercentChangedListener: " + String.valueOf(percent));
55+
}
56+
}
57+
});
6358
```
6459

65-
### ScratchTextView
6660

67-
##### XML
61+
Example
62+
--------
6863

6964
```xml
70-
<com.cooltechworks.views.ScratchTextView
71-
android:layout_width="300dp"
72-
android:layout_height="300dp"
73-
android:gravity="center|end"
74-
android:text="@string/flat_200"
75-
android:textSize="15sp"
76-
android:textStyle="bold"
77-
app:overlay_image="@drawable/scratch_card"
78-
app:tile_mode="CLAMP"
79-
app:overlay_width="300dp"
80-
app:overlay_height="300dp"/>
81-
82-
```
83-
84-
##### JAVA
65+
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
66+
xmlns:app="http://schemas.android.com/apk/res-auto"
67+
xmlns:tools="http://schemas.android.com/tools"
68+
android:layout_width="match_parent"
69+
android:layout_height="match_parent"
70+
android:gravity="center"
71+
tools:context=".MainActivity">
72+
73+
<ImageView
74+
android:gravity="center"
75+
android:layout_width="300dp"
76+
android:layout_height="300dp"
77+
android:src="@drawable/anup"/>
78+
79+
<com.anupkumarpanwar.scratchview.ScratchView
80+
android:id="@+id/scratch_view"
81+
android:layout_width="300dp"
82+
android:layout_height="300dp"
83+
app:overlay_image="@drawable/scratch_card"
84+
app:tile_mode="CLAMP"
85+
app:overlay_width="300dp"
86+
app:overlay_height="300dp"
87+
/>
88+
89+
</RelativeLayout>
8590

86-
```java
87-
ScratchTextView scratchTextView = new ScratchTextView(this);
88-
89-
scratchTextView.setRevealListener(new ScratchTextView.IRevealListener() {
90-
@Override
91-
public void onRevealed(ScratchTextView tv) {
92-
//on reveal
93-
}
94-
95-
96-
@Override
97-
public void onRevealPercentChangedListener(ScratchTextView stv, float percent) {
98-
// on text percent reveal
99-
}
100-
});
10191
```
10292

103-
10493
Attributes
10594
--------
10695
| Attribute | Description | Values |
@@ -111,7 +100,7 @@ Attributes
111100
| `app:overlay_height` | Height of the overlay pattern | 300dp |
112101

113102

114-
Adding to your project
103+
Installation
115104
------------------------
116105

117106
- Add the following configuration in your build.gradle file.
@@ -130,17 +119,4 @@ dependencies {
130119
Developed By
131120
------------
132121

133-
* Harish Sridharan - <[email protected]>
134-
135-
136-
Customised By
137-
------------
138-
139-
* Anup Kumar Panwar - <[email protected]>
140-
141-
142-
143-
[scratch_image]:https://raw.githubusercontent.com/cooltechworks/ScratchView/2ec97c9a539d5976b68bf62ec07df8c727d72be2/screenshots/scratch_image_view_demo.gif
144-
[scratch_text]:https://raw.githubusercontent.com/cooltechworks/ScratchView/master/screenshots/scratch_text_view_demo.gif
145-
146-
122+
* Anup Kumar Panwar - <[email protected]>

0 commit comments

Comments
 (0)