4
4
[ ![ Build Status] ( https://travis-ci.org/skydoves/ElasticViews.svg?branch=master )] ( https://travis-ci.org/skydoves/ElasticViews )
5
5
[ ![ Android Weekly] ( https://img.shields.io/badge/Android%20Weekly-%23336-orange.svg )] ( https://androidweekly.net/issues/issue-336 ) <br >
6
6
7
- A library that lets you implement elastic touch animation easily .
7
+ An easy way to implement elastic touch effect for Android .
8
8
9
9
![ gif0] ( https://user-images.githubusercontent.com/24237865/48674497-53e2f180-eb90-11e8-86fb-476f841b3e32.gif )
10
10
![ gif1] ( https://user-images.githubusercontent.com/24237865/48674498-53e2f180-eb90-11e8-8313-aa94b34a40d2.gif )
@@ -18,7 +18,7 @@ repositories {
18
18
}
19
19
20
20
dependencies {
21
- implementation "com.github.skydoves:elasticviews:2.0.2 "
21
+ implementation "com.github.skydoves:elasticviews:2.0.3 "
22
22
}
23
23
```
24
24
@@ -55,17 +55,17 @@ public void onClick(View v) {
55
55
### ElasticButton
56
56
``` gradle
57
57
<com.skydoves.elasticviews.ElasticButton
58
- android:id="@+id/elasticbutton"
59
- android:layout_width="match_parent"
60
- android:layout_height="50dp"
61
- app:button_backgroundColor="#30354b"
62
- app:button_round="20"
63
- app:button_scale="0.7"
64
- app:button_duration="400"
65
- app:button_labelText="Elastic Button"
66
- app:button_labelColor="#ffffff"
67
- app:button_labelSize="16"
68
- app:button_labelStyle="bold"/>
58
+ android:id="@+id/elasticbutton"
59
+ android:layout_width="match_parent"
60
+ android:layout_height="50dp"
61
+ app:button_backgroundColor="#30354b"
62
+ app:button_round="20"
63
+ app:button_scale="0.7"
64
+ app:button_duration="400"
65
+ app:button_labelText="Elastic Button"
66
+ app:button_labelColor="#ffffff"
67
+ app:button_labelSize="16"
68
+ app:button_labelStyle="bold"/>
69
69
```
70
70
71
71
### ElasticButton use like TextView
@@ -77,112 +77,130 @@ app:button_backgroundColor="@android:color/transparent"
77
77
### ElasticCheckButton
78
78
``` gradle
79
79
<com.skydoves.elasticviews.ElasticCheckButton
80
- android:id="@+id/elasticcheckbutton"
81
- android:layout_width="match_parent"
82
- android:layout_height="50dp"
83
- app:checkbutton_backgroundColor="#30354b"
84
- app:checkbutton_round="30"
85
- app:checkbutton_scale="0.9"
86
- app:checkbutton_duration="400"
87
- app:checkbutton_labelText="Elastic CheckButton"
88
- app:checkbutton_labelColor="#ffffff"
89
- app:checkbutton_labelSize="16"
90
- app:checkbutton_labelStyle="bold"
91
- app:checkbutton_alpha="0.5"
92
- app:checkbutton_ischecked="false"/>
80
+ android:id="@+id/elasticcheckbutton"
81
+ android:layout_width="match_parent"
82
+ android:layout_height="50dp"
83
+ app:checkbutton_backgroundColor="#30354b"
84
+ app:checkbutton_round="30"
85
+ app:checkbutton_scale="0.9"
86
+ app:checkbutton_duration="400"
87
+ app:checkbutton_labelText="Elastic CheckButton"
88
+ app:checkbutton_labelColor="#ffffff"
89
+ app:checkbutton_labelSize="16"
90
+ app:checkbutton_labelStyle="bold"
91
+ app:checkbutton_alpha="0.5"
92
+ app:checkbutton_ischecked="false"/>
93
93
```
94
94
95
95
### ElasticImageView
96
96
``` gradle
97
97
<com.skydoves.elasticviews.ElasticImageView
98
- android:id="@+id/elasticimageview"
99
- android:layout_width="64dp"
100
- android:layout_height="64dp"
101
- android:scaleType="fitXY"
102
- android:src="@drawable/ic_question"
103
- app:imageview_duration="500"
104
- app:imageview_scale="0.7"/>
98
+ android:id="@+id/elasticimageview"
99
+ android:layout_width="64dp"
100
+ android:layout_height="64dp"
101
+ android:scaleType="fitXY"
102
+ android:src="@drawable/ic_question"
103
+ app:imageview_duration="500"
104
+ app:imageview_scale="0.7"/>
105
105
```
106
106
107
107
### ElasticFloatingButton
108
108
``` gradle
109
109
<com.skydoves.elasticviews.ElasticFloatingActionButton
110
- android:id="@+id/elasticfab"
111
- android:layout_width="64dp"
112
- android:layout_height="64dp"
113
- android:src="@drawable/ic_add"
114
- app:fabSize="normal"
115
- app:fabutton_duration="400"
116
- app:fabutton_scale="0.85"/>
110
+ android:id="@+id/elasticfab"
111
+ android:layout_width="64dp"
112
+ android:layout_height="64dp"
113
+ android:src="@drawable/ic_add"
114
+ app:fabSize="normal"
115
+ app:fabutton_duration="400"
116
+ app:fabutton_scale="0.85"/>
117
117
```
118
118
119
119
### ElasticLayout
120
- ElasticLayout gives elastic animation to all child views.
120
+ ElasticLayout implements elastic animation to all child views.
121
121
122
122
``` gradle
123
123
<com.skydoves.elasticviews.ElasticLayout
124
- android:id="@+id/elasticlayout"
125
- android:layout_width="match_parent"
126
- android:layout_height="80dp"
127
- app:layout_backgroundColor="#30354b"
128
- app:layout_duration="500"
129
- app:layout_scale="0.85">
130
-
131
- <TextView
132
- android:id="@+id/textView0"
133
- android:layout_width="match_parent"
134
- android:layout_height="wrap_content"
135
- android:text="This is"
136
- android:textColor="#ffffff"
137
- android:textSize="18sp" />
138
-
139
- <TextView
140
- android:layout_below="@+id/textView1"
141
- android:layout_width="match_parent"
142
- android:layout_height="wrap_content"
143
- android:layout_alignParentBottom="true"
144
- android:text="ElasticLayout"
145
- android:textColor="#ffffff"
146
- android:textSize="18sp"
147
- android:gravity="end" />
124
+ android:id="@+id/elasticlayout"
125
+ android:layout_width="match_parent"
126
+ android:layout_height="80dp"
127
+ app:layout_backgroundColor="#30354b"
128
+ app:layout_duration="500"
129
+ app:layout_scale="0.85">
130
+
131
+ <TextView
132
+ android:id="@+id/textView0"
133
+ android:layout_width="match_parent"
134
+ android:layout_height="wrap_content"
135
+ android:text="This is"
136
+ android:textColor="#ffffff"
137
+ android:textSize="18sp" />
138
+
139
+ <TextView
140
+ android:layout_below="@+id/textView1"
141
+ android:layout_width="match_parent"
142
+ android:layout_height="wrap_content"
143
+ android:layout_alignParentBottom="true"
144
+ android:text="ElasticLayout"
145
+ android:textColor="#ffffff"
146
+ android:textSize="18sp"
147
+ android:gravity="end" />
148
148
</com.skydoves.elasticviews.ElasticLayout>
149
149
```
150
150
151
151
### ElasticAnmimation
152
- ElasticAnimation lets we can implement elastic animation on all of the views . <br >
152
+ ElasticAnimation implements elastic animations for android views or view groups . <br >
153
153
``` java
154
154
new ElasticAnimation (clickedView). setScaleX(0.9f ). setScaleY(0.9f ). setDuration(400 )
155
155
.setOnFinishListener(onFinishListener). doAction();
156
156
```
157
- or we can set ViewPropertyAnimatorListener using setListener method and detect animation start and end.
157
+
158
+ #### ViewPropertyAnimatorListener
159
+ we can set ` ViewPropertyAnimatorListener ` using ` setListener ` method and detect animation's status.
158
160
``` java
159
161
.setListener(new ViewPropertyAnimatorListener () {
160
- @Override
161
- public void onAnimationStart (View view ) {
162
- }
163
-
164
- @Override
165
- public void onAnimationEnd (View view ) {
166
- finishListener. onFinished();
167
- }
168
-
169
- @Override
170
- public void onAnimationCancel (View view ) {
171
- }
162
+ @Override
163
+ public void onAnimationStart (View view ) {
164
+ // do something
165
+ }
166
+
167
+ Override
168
+ public void onAnimationEnd (View view ) {
169
+ finishListener. onFinished();
170
+ }
171
+
172
+ Override
173
+ public void onAnimationCancel (View view ) {
174
+ // do something
175
+ }
172
176
});
173
177
```
174
178
175
179
#### Kotlin Extension
176
180
ElasticAnimation supports kotlin extension ` elasticAnimation ` .
177
181
``` kotlin
178
182
val anim = textView.elasticAnimation(0.8f , 0.8f , 400 , object : ElasticFinishListener {
179
- override fun onFinished () {
180
- // do anything
181
- }
182
- })
183
+ override fun onFinished () {
184
+ // do anything
185
+ }
186
+ })
183
187
anim.doAction()
184
188
```
185
189
190
+ #### Kotlin dsl
191
+ ``` kotlin
192
+ elasticAnimation(this ) {
193
+ setDuration(duration)
194
+ setScaleX(scale)
195
+ setScaleY(scale)
196
+ setOnFinishListener(object : ElasticFinishListener {
197
+ override fun onFinished () {
198
+ onClick()
199
+ }
200
+ })
201
+ }.doAction()
202
+ ```
203
+
186
204
#### Example : Normal Button
187
205
we can implement animation on all of the views like below.
188
206
``` java
0 commit comments