-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathActivityAnimation12.java
273 lines (251 loc) · 10.1 KB
/
ActivityAnimation12.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
package com.xibei.personaldesign.itemDemo;
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import com.xibei.personaldesign.R;
public class ActivityAnimation12 extends Activity implements View.OnClickListener {
TextView textView1, textView2;
Button btn_01, btn_02,btn_03,
btn_04,btn_05,btn_06,
btn_07,btn_08,btn_09,
btn_10,btn_11,btn_12,
btn_13,btn_14,btn_15,btn_16;
ObjectAnimator tv1BgAnimator,tv1Translate,tv1ScaleX,
tv2BgAnimator,tv2Translate,tv2ScaleX;
final int TV1_BG =1;
final int TV1_BG_SCLAEX =2;
final int TV1_BG_SCLAEX_TRANSLATIONY =3;
final int TV2_BG =4;
final int TV2_BG_SCLAEX =5;
final int TV2_BG_SCLAEX_TRANSLATIONY =6;
final int _TV1_TV2 =7;
final int _TV2__TV1 =8;
final int TV1__TV2 =9;
final int _TV1_BG_SCLAEX_TRANSLATIONY =10;
final int _TV1_TRANSLATIONY_SCLAEX_BG =11;
final int _TV2_BG_SCLAEX_TRANSLATIONY =12;
final int _TV2_TRANSLATIONY_SCLAEX_BG =13;
final int _TV1_TRANSLATIONY_SCLAEX_BG_TV2_TRANSLATIONY_SCLAEX_BG =14;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_item_animation_12);
textView1 = findViewById(R.id.textview1);
textView2 = findViewById(R.id.textview2);
btn_01 = findViewById(R.id.btn_01);
btn_02 = findViewById(R.id.btn_02);
btn_03 = findViewById(R.id.btn_03);
btn_04 = findViewById(R.id.btn_04);
btn_05 = findViewById(R.id.btn_05);
btn_06 = findViewById(R.id.btn_06);
btn_07 = findViewById(R.id.btn_07);
btn_08 = findViewById(R.id.btn_08);
btn_09 = findViewById(R.id.btn_09);
btn_10 = findViewById(R.id.btn_10);
btn_11 = findViewById(R.id.btn_11);
btn_11 = findViewById(R.id.btn_11);
btn_12 = findViewById(R.id.btn_12);
btn_13 = findViewById(R.id.btn_13);
btn_14 = findViewById(R.id.btn_14);
btn_15 = findViewById(R.id.btn_15);
btn_16 = findViewById(R.id.btn_16);
btn_01.setOnClickListener(this);
btn_02.setOnClickListener(this);
btn_03.setOnClickListener(this);
btn_04.setOnClickListener(this);
btn_05.setOnClickListener(this);
btn_06.setOnClickListener(this);
btn_07.setOnClickListener(this);
btn_08.setOnClickListener(this);
btn_09.setOnClickListener(this);
btn_10.setOnClickListener(this);
btn_11.setOnClickListener(this);
btn_12.setOnClickListener(this);
btn_13.setOnClickListener(this);
btn_14.setOnClickListener(this);
btn_15.setOnClickListener(this);
btn_16.setOnClickListener(this);
}
@Override
public void onClick(View v) {
initAnimator();
switch (v.getId()){
case R.id.btn_01:
doAnimator(false);
break;
case R.id.btn_02:
doAnimator(true);
break;
case R.id.btn_03:
animatorSetBuilder(TV1_BG);
break;
case R.id.btn_04:
animatorSetBuilder(TV1_BG_SCLAEX);
break;
case R.id.btn_05:
animatorSetBuilder(TV1_BG_SCLAEX_TRANSLATIONY);
break;
case R.id.btn_06:
animatorSetBuilder(TV2_BG);
break;
case R.id.btn_07:
animatorSetBuilder(TV2_BG_SCLAEX);
break;
case R.id.btn_08:
animatorSetBuilder(TV2_BG_SCLAEX_TRANSLATIONY);
break;
case R.id.btn_09:
animatorSetBuilder(_TV1_TV2);
break;
case R.id.btn_10:
animatorSetBuilder(_TV2__TV1);
break;
case R.id.btn_11:
animatorSetBuilder(TV1__TV2);
break;
case R.id.btn_12:
animatorSetBuilder(_TV1_BG_SCLAEX_TRANSLATIONY);
break;
case R.id.btn_13:
animatorSetBuilder(_TV1_TRANSLATIONY_SCLAEX_BG);
break;
case R.id.btn_14:
animatorSetBuilder(_TV2_BG_SCLAEX_TRANSLATIONY);
break;
case R.id.btn_15:
animatorSetBuilder(_TV2_TRANSLATIONY_SCLAEX_BG);
break;
case R.id.btn_16:
animatorSetBuilder(_TV1_TRANSLATIONY_SCLAEX_BG_TV2_TRANSLATIONY_SCLAEX_BG);
break;
}
}
private void initAnimator() {
tv1BgAnimator = ObjectAnimator.ofInt(textView1, "BackgroundColor", 0xff112233, 0xff223344, 0xff334455);
tv1Translate = ObjectAnimator.ofFloat(textView1, "translationY", 0, 10, 20, 30, 40, 50, 0);
tv1ScaleX = ObjectAnimator.ofFloat(textView1, "scaleX", 1f, 1.1f, 1.2f, 1.1f, 1f);
tv2BgAnimator = ObjectAnimator.ofInt(textView2, "BackgroundColor", 0xff112233, 0xff223344, 0xff334455);
tv2Translate = ObjectAnimator.ofFloat(textView2, "translationY", 0, 10, 20, 30, 40, 50, 0);
tv2ScaleX = ObjectAnimator.ofFloat(textView2, "scaleX", 1f, 1.1f, 1.2f, 1.1f, 1f);
}
private void doAnimator(boolean together){
AnimatorSet animatorSet = new AnimatorSet();
if (together){
animatorSet.playTogether(tv1BgAnimator,tv1Translate,tv1ScaleX,
tv2BgAnimator,tv2Translate,tv2ScaleX);
}else {
animatorSet.playSequentially(tv1BgAnimator,tv1Translate,tv1ScaleX,
tv2BgAnimator,tv2Translate,tv2ScaleX);
}
animatorSet.setDuration(2000);
animatorSet.start();
}
private void animatorSetBuilder(int animNo){
AnimatorSet animatorSet = new AnimatorSet();
switch (animNo){
case TV1_BG:
AnimatorSet.Builder builder = animatorSet.play(tv1BgAnimator);
break;
case TV1_BG_SCLAEX:
AnimatorSet.Builder builder1 = animatorSet
.play(tv1BgAnimator)
.with(tv1ScaleX);
break;
case TV1_BG_SCLAEX_TRANSLATIONY:
AnimatorSet.Builder builder2 = animatorSet
.play(tv1BgAnimator)
.with(tv1ScaleX)
.with(tv1Translate);
break;
case TV2_BG:
AnimatorSet.Builder builder3 = animatorSet.play(tv2BgAnimator);
break;
case TV2_BG_SCLAEX:
AnimatorSet.Builder builder4 = animatorSet
.play(tv2BgAnimator)
.with(tv2ScaleX);
break;
case TV2_BG_SCLAEX_TRANSLATIONY:
AnimatorSet.Builder builder5 = animatorSet
.play(tv2BgAnimator)
.with(tv2ScaleX)
.with(tv2Translate);
break;
case _TV1_TV2:
AnimatorSet.Builder builder6= animatorSet
.play(tv1BgAnimator)
.with(tv1ScaleX)
.with(tv1Translate)
.before(tv2BgAnimator)
.before(tv2ScaleX)
.before(tv2Translate);
break;
case _TV2__TV1:
AnimatorSet.Builder builder7= animatorSet
.play(tv2BgAnimator)
.with(tv2ScaleX)
.with(tv2Translate)
.before(tv1BgAnimator)
.before(tv1ScaleX)
.before(tv1Translate);
break;
case TV1__TV2:
AnimatorSet.Builder builder8= animatorSet
.play(tv2BgAnimator)
.with(tv2ScaleX)
.with(tv2Translate)
.with(tv1BgAnimator)
.with(tv1ScaleX)
.with(tv1Translate);
break;
case _TV1_BG_SCLAEX_TRANSLATIONY:
tv1ScaleX.setStartDelay(2000);
tv1Translate.setStartDelay(4000);
AnimatorSet.Builder builder9= animatorSet
.play(tv1BgAnimator)
.with(tv1ScaleX)
.with(tv1Translate);
break;
case _TV1_TRANSLATIONY_SCLAEX_BG:
tv1ScaleX.setStartDelay(2000);
AnimatorSet.Builder builder10= animatorSet
.play(tv1BgAnimator)
.after(tv1ScaleX)
.after(tv1Translate);
break;
case _TV2_BG_SCLAEX_TRANSLATIONY:
tv2ScaleX.setStartDelay(2000);
tv2Translate.setStartDelay(4000);
AnimatorSet.Builder builder11= animatorSet
.play(tv2BgAnimator)
.with(tv2ScaleX)
.with(tv2Translate);
break;
case _TV2_TRANSLATIONY_SCLAEX_BG:
tv2ScaleX.setStartDelay(2000);
AnimatorSet.Builder builder12= animatorSet
.play(tv2BgAnimator)
.after(tv2ScaleX)
.after(tv2Translate);
break;
case _TV1_TRANSLATIONY_SCLAEX_BG_TV2_TRANSLATIONY_SCLAEX_BG:
tv1ScaleX.setStartDelay(2000);
tv2ScaleX.setStartDelay(2000);
tv2BgAnimator.setStartDelay(4000);
AnimatorSet.Builder builder13= animatorSet
.play(tv1BgAnimator)
.after(tv1ScaleX)
.after(tv1Translate)
.before(tv2Translate)
.before(tv2ScaleX)
.before(tv2BgAnimator);
break;
}
animatorSet.setDuration(2000);
animatorSet.start();
}
}