Android第四十期 - 动画数字三元归一
最近太忙,天天都下半夜,但是还是做出来一些成绩,这个效果以后大家需要的话可以改改,代码已经整理好,效果如下:
想想还是跟大家讲一下吧,这些还是有一些技巧的。
首先是字体部分,动态的变化会随着上下的滚动递增递减,效果如下:
首先是布局文件:
|
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
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
|
<?xml version=
"1.0"
encoding=
"utf-8"
?>
<com.yuan.mytmall.MagicScrollView xmlns:android=
"http://schemas.android.com/apk/res/android"
android:id=
"@+id/magic_scroll"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:background=
"@color/white"
android:scrollbars=
"none"
>
<LinearLayout
android:id=
"@+id/container"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:orientation=
"vertical"
>
<RelativeLayout
android:id=
"@+id/code_layout"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:background=
"@color/cyan"
android:orientation=
"vertical"
android:paddingBottom=
"20dp"
android:paddingTop=
"20dp"
>
<TextView
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_alignParentLeft=
"true"
android:layout_marginLeft=
"10dp"
android:text=
"当前账户:"
android:textColor=
"@color/white"
android:textSize=
"18sp"
/>
<FrameLayout
android:layout_width=
"120dp"
android:layout_height=
"120dp"
android:layout_centerInParent=
"true"
>
<com.geek.view.RoundImageViewByXfermode
android:id=
"@+id/patientmg_code_img3"
android:layout_width=
"100dp"
android:layout_height=
"100dp"
android:layout_gravity=
"center"
android:contentDescription=
"@null"
android:padding=
"7dp"
android:src=
"@drawable/white3"
/>
</FrameLayout>
<FrameLayout
android:layout_width=
"120dp"
android:layout_height=
"120dp"
android:layout_centerInParent=
"true"
>
<com.geek.view.RoundImageViewByXfermode
android:id=
"@+id/patientmg_code_img2"
android:layout_width=
"100dp"
android:layout_height=
"100dp"
android:layout_gravity=
"center"
android:contentDescription=
"@null"
android:padding=
"7dp"
android:src=
"@drawable/white2"
/>
</FrameLayout>
<FrameLayout
android:layout_width=
"120dp"
android:layout_height=
"120dp"
android:layout_centerInParent=
"true"
>
<com.geek.view.RoundImageViewByXfermode
android:id=
"@+id/patientmg_code_img1"
android:layout_width=
"100dp"
android:layout_height=
"100dp"
android:layout_gravity=
"center"
android:contentDescription=
"@null"
android:padding=
"7dp"
android:src=
"@drawable/white1"
/>
</FrameLayout>
<FrameLayout
android:layout_width=
"120dp"
android:layout_height=
"120dp"
android:layout_centerInParent=
"true"
>
<com.geek.view.RoundImageViewByXfermode
android:id=
"@+id/patientmg_code_img"
android:layout_width=
"100dp"
android:layout_height=
"100dp"
android:layout_gravity=
"center"
android:contentDescription=
"@null"
android:padding=
"7dp"
android:src=
"@drawable/white0"
/>
</FrameLayout>
<FrameLayout
android:layout_width=
"100dp"
android:layout_height=
"100dp"
android:layout_centerInParent=
"true"
>
<RelativeLayout
android:id=
"@+id/rllob"
android:layout_width=
"fill_parent"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center"
>
<com.yuan.mytmall.MagicTextView
android:id=
"@+id/tv_qian"
android:layout_width=
"fill_parent"
android:layout_height=
"wrap_content"
android:gravity=
"center"
android:text=
"0.0"
android:textColor=
"@color/oriange"
android:textSize=
"20sp"
/>
</RelativeLayout>
<TextView
android:id=
"@+id/tv_nick3"
android:layout_width=
"fill_parent"
android:layout_height=
"wrap_content"
android:layout_below=
"@+id/rllob"
android:layout_gravity=
"bottom"
android:gravity=
"center"
android:paddingBottom=
"5dp"
android:text=
"元"
android:textColor=
"@color/gray"
android:textSize=
"20sp"
/>
</FrameLayout>
</RelativeLayout>
<LinearLayout
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:background=
"@color/oriange"
android:orientation=
"vertical"
android:padding=
"15dp"
>
<TextView
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:text=
"昨日收益"
android:textColor=
"@color/white"
android:textSize=
"20sp"
/>
<com.yuan.mytmall.MagicTextView
android:id=
"@+id/income_money"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_marginTop=
"15dp"
android:text=
"0.00"
android:textColor=
"@color/white"
android:textSize=
"60sp"
/>
</LinearLayout>
<TextView
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_marginLeft=
"15dp"
android:layout_marginTop=
"20dp"
android:text=
"总金额(元)"
android:textColor=
"@color/gray"
android:textSize=
"20sp"
/>
<com.yuan.mytmall.MagicTextView
android:id=
"@+id/total_money"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_marginLeft=
"15dp"
android:layout_marginTop=
"5dp"
android:text=
"0.00"
android:textColor=
"@color/oriange"
android:textSize=
"45sp"
/>
<LinearLayout
android:id=
"@+id/income_total_bar"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_marginTop=
"20dp"
android:background=
"@color/light_gray"
>
<LinearLayout
android:layout_width=
"0dp"
android:layout_height=
"match_parent"
android:layout_weight=
"1"
android:orientation=
"vertical"
android:padding=
"10dp"
>
<TextView
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:text=
"累计收益(元)"
android:textColor=
"@color/gray"
android:textSize=
"20sp"
/>
<com.yuan.mytmall.MagicTextView
android:id=
"@+id/income_total_txt"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginTop=
"5dp"
android:text=
"0.0"
android:textColor=
"@color/black"
android:textSize=
"30sp"
/>
</LinearLayout>
<LinearLayout
android:layout_width=
"0dp"
android:layout_height=
"match_parent"
android:layout_weight=
"1"
android:orientation=
"vertical"
android:padding=
"10dp"
>
<TextView
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:text=
"七日年化收益率"
android:textColor=
"@color/gray"
android:textSize=
"20sp"
/>
<com.yuan.mytmall.MagicTextView
android:id=
"@+id/income_sevdays_txt"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginTop=
"5dp"
android:text=
"0.00"
android:textColor=
"@color/black"
android:textSize=
"30sp"
/>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:id=
"@+id/income_nearly_bar"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:background=
"@color/light_gray"
>
<LinearLayout
android:layout_width=
"0dp"
android:layout_height=
"match_parent"
android:layout_weight=
"1"
android:orientation=
"vertical"
android:padding=
"10dp"
>
<TextView
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:text=
"近一周收益(元)"
android:textColor=
"@color/gray"
android:textSize=
"20sp"
/>
<com.yuan.mytmall.MagicTextView
android:id=
"@+id/income_week_txt"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginTop=
"5dp"
android:text=
"0.00"
android:textColor=
"@color/black"
android:textSize=
"30sp"
/>
</LinearLayout>
<LinearLayout
android:layout_width=
"0dp"
android:layout_height=
"match_parent"
android:layout_weight=
"1"
android:orientation=
"vertical"
android:padding=
"10dp"
>
<TextView
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:text=
"近一月收益(元)"
android:textColor=
"@color/gray"
android:textSize=
"20sp"
/>
<com.yuan.mytmall.MagicTextView
android:id=
"@+id/income_month_txt"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginTop=
"5dp"
android:text=
"0.0"
android:textColor=
"@color/black"
android:textSize=
"30sp"
/>
</LinearLayout>
</LinearLayout>
<TextView
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_marginTop=
"15dp"
android:gravity=
"center"
android:text=
"南京市"
android:textColor=
"@color/oriange"
android:textSize=
"25sp"
/>
<TextView
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_marginTop=
"8dp"
android:gravity=
"center"
android:text=
"你的收益战胜了"
android:textColor=
"@color/gray"
/>
<LinearLayout
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_marginTop=
"15dp"
android:gravity=
"center"
>
<com.yuan.mytmall.MagicTextView
android:id=
"@+id/overperson_percent"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:gravity=
"center"
android:text=
"0.00"
android:textColor=
"@color/oriange"
android:textSize=
"35sp"
/>
<TextView
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginLeft=
"2dp"
android:text=
"%"
android:textColor=
"@color/oriange"
android:textSize=
"35sp"
/>
</LinearLayout>
<TextView
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:gravity=
"center"
android:text=
"超过"
android:textColor=
"@color/gray"
/>
<com.yuan.mytmall.MagicTextView
android:id=
"@+id/overperson_count"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:gravity=
"center"
android:text=
"0"
android:textColor=
"@color/gray"
android:textSize=
"25sp"
/>
<LinearLayout
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_marginTop=
"15dp"
android:gravity=
"center"
>
<com.yuan.mytmall.MagicTextView
android:id=
"@+id/overperson_percent2"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:gravity=
"center"
android:text=
"0.00"
android:textColor=
"@color/oriange"
android:textSize=
"35sp"
/>
<TextView
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginLeft=
"2dp"
android:text=
"%"
android:textColor=
"@color/oriange"
android:textSize=
"35sp"
/>
</LinearLayout>
<LinearLayout
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_marginTop=
"15dp"
android:gravity=
"center"
>
</LinearLayout>
</LinearLayout>
</com.yuan.mytmall.MagicScrollView>
|
基类MagicScrollView:
|
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
|
package
com.yuan.mytmall;
import
java.util.ArrayList;
import
java.util.List;
import
android.content.Context;
import
android.util.AttributeSet;
import
android.widget.ScrollView;
public
class
MagicScrollView
extends
ScrollView {
private
List<ScrollListener> mListeners =
new
ArrayList<MagicScrollView.ScrollListener>();
private
int
state =
0
;
public
static
final
int
UP =
1
;
public
static
final
int
DOWN =
2
;
public
static
final
int
STOP =
3
;
public
interface
ScrollListener {
void
onScrollChanged(
int
state,
int
t);
}
public
MagicScrollView(Context context) {
super
(context);
}
public
MagicScrollView(Context context, AttributeSet set) {
super
(context, set);
}
public
MagicScrollView(Context context, AttributeSet set,
int
defStyle) {
super
(context, set, defStyle);
}
public
void
AddListener(ScrollListener listener) {
if
(mListeners ==
null
)
mListeners =
new
ArrayList<MagicScrollView.ScrollListener>();
mListeners.add(listener);
}
@Override
protected
void
onScrollChanged(
int
l,
int
t,
int
oldl,
int
oldt) {
super
.onScrollChanged(l, t, oldl, oldt);
if
(t > oldt) {
state = UP;
}
else
if
(t < oldt) {
state = DOWN;
}
else
{
state = STOP;
}
sendScroll(state, t);
}
public
void
sendScroll(
int
state,
int
scroll) {
for
(ScrollListener listener : mListeners) {
listener.onScrollChanged(state, scroll);
}
}
}
|
文字的基类MagicTextView:
|
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
|
package
com.yuan.mytmall;
import
java.math.BigDecimal;
import
java.text.DecimalFormat;
import
android.content.Context;
import
android.os.Handler;
import
android.os.Message;
import
android.util.AttributeSet;
import
android.widget.TextView;
import
com.yuan.mytmall.MagicScrollView.ScrollListener;
public
class
MagicTextView
extends
TextView
implements
ScrollListener {
// view 自身高度
private
int
mHeight;
// view 距离scrollView最顶端高度
private
int
locHeight;
// 递减/递增 的变量值
private
double
mRate;
// view 设置的值
private
double
mValue;
// 当前显示的值
private
double
mCurValue;
// 当前变化后最终状态的目标值
private
double
mGalValue;
// 控制加减法
private
int
rate =
1
;
// 当前变化状态(增/减/不变)
private
int
mState =
0
;
private
boolean
refreshing;
private
static
final
int
REFRESH =
1
;
private
static
final
int
SCROLL =
2
;
// 偏移量 主要用来进行校正距离。
private
static
final
int
OFFSET =
20
;
DecimalFormat fnum =
new
DecimalFormat(
"0.00"
);
private
Handler mHandler =
new
Handler() {
public
void
handleMessage(android.os.Message msg) {
switch
(msg.what) {
case
REFRESH:
if
(rate * mCurValue < mGalValue) {
refreshing =
true
;
setText(fnum.format(mCurValue));
mCurValue += mRate * rate;
mHandler.sendEmptyMessageDelayed(REFRESH,
50
);
}
else
{
refreshing =
false
;
setText(fnum.format(mGalValue));
}
break
;
case
SCROLL:
doScroll(msg.arg1, msg.arg2);
break
;
default
:
break
;
}
};
};
public
MagicTextView(Context context) {
super
(context);
}
public
MagicTextView(Context context, AttributeSet set) {
super
(context, set);
}
public
MagicTextView(Context context, AttributeSet set,
int
defStyle) {
super
(context, set, defStyle);
}
public
void
setLocHeight(
int
height) {
locHeight = height;
}
public
void
setValue(
double
value) {
mCurValue =
0.00
;
mGalValue = isShown() ? value :
0
;
mValue = value;
mRate = (
double
) (mValue /
20.00
);
BigDecimal b =
new
BigDecimal(mRate);
mRate = b.setScale(
2
, BigDecimal.ROUND_HALF_UP).doubleValue();
}
@Override
public
void
onScrollChanged(
int
state,
int
scroll) {
Message msg = mHandler.obtainMessage();
msg.what = SCROLL;
msg.arg1 = state;
msg.arg2 = scroll;
mHandler.sendMessage(msg);
}
private
void
doScroll(
int
state,
int
scroll) {
if
(mState == state && refreshing)
return
;
mState = state;
if
(doMinus(scroll)) {
rate = -
1
;
mGalValue =
0
;
}
else
if
(doPlus(scroll)) {
rate =
1
;
mGalValue = mValue;
}
mHandler.sendEmptyMessage(REFRESH);
}
private
boolean
doPlus(
int
scroll) {
if
(isShown() && (scroll + PayActivity.mWinheight > locHeight + OFFSET)
&& (mState == MagicScrollView.UP))
return
true
;
if
(isShown() && (scroll < locHeight) && mState == MagicScrollView.DOWN)
return
true
;
return
false
;
}
private
boolean
doMinus(
int
scroll) {
if
(isShown() && (scroll > locHeight) && (mState == MagicScrollView.UP))
return
true
;
if
(isShown() && (scroll + PayActivity.mWinheight - mHeight < locHeight - OFFSET)
&& (mState == MagicScrollView.DOWN))
return
true
;
return
false
;
}
@Override
protected
void
onMeasure(
int
widthMeasureSpec,
int
heightMeasureSpec) {
super
.onMeasure(widthMeasureSpec, heightMeasureSpec);
// 执行完onMeasure后即可获得view的宽度
mHeight = getMeasuredHeight();
}
}
|
最后是Activity:
|
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
|
package
com.yuan.mytmall;
import
android.app.Activity;
import
android.content.res.Configuration;
import
android.graphics.Rect;
import
android.os.Bundle;
import
android.os.Handler;
import
android.util.Log;
import
android.view.animation.Animation;
import
android.view.animation.AnimationUtils;
import
android.view.animation.DecelerateInterpolator;
import
android.view.animation.LinearInterpolator;
import
android.widget.ImageView;
import
android.widget.LinearLayout;
public
class
PayActivity
extends
Activity {
private
MagicTextView tv_qian;
private
MagicScrollView mScrollView;
private
MagicTextView mIncomeTxt;
private
MagicTextView mTotalMoneyTxt;
private
MagicTextView mIncTotalTxt;
private
MagicTextView mIncSevTxt;
private
MagicTextView mIncWeekTxt;
private
MagicTextView mIncMonTxt;
private
MagicTextView mOverPerTxt;
private
MagicTextView mOverPerTxt2;
private
MagicTextView mOverCountTxt;
private
LinearLayout mContainer;
public
static
int
mWinheight;
int
[] location =
new
int
[
2
];
private
ImageView infoOperatingIV1, infoOperatingIV2, infoOperatingIV3;
private
Animation operatingAnim1;
private
Animation operatingAnim2;
private
Animation operatingAnim3;
public
void
onConfigurationChanged(Configuration newConfig) {
super
.onConfigurationChanged(newConfig);
if
(operatingAnim1 !=
null
&& infoOperatingIV1 !=
null
&& operatingAnim1.hasStarted()) {
infoOperatingIV1.clearAnimation();
infoOperatingIV1.startAnimation(operatingAnim1);
}
if
(operatingAnim2 !=
null
&& infoOperatingIV2 !=
null
&& operatingAnim2.hasStarted()) {
infoOperatingIV2.clearAnimation();
infoOperatingIV2.startAnimation(operatingAnim2);
}
if
(operatingAnim3 !=
null
&& infoOperatingIV3 !=
null
&& operatingAnim3.hasStarted()) {
infoOperatingIV3.clearAnimation();
infoOperatingIV3.startAnimation(operatingAnim3);
}
}
private
Handler mHandler =
new
Handler() {
public
void
handleMessage(android.os.Message msg) {
int
height = mContainer.getMeasuredHeight();
Log.d(
"height is ====>"
,
""
+ height);
onMeasureTxt(tv_qian);
onMeasureTxt(mIncomeTxt);
onMeasureTxt(mTotalMoneyTxt);
onMeasureTxt(mIncTotalTxt);
onMeasureTxt(mIncSevTxt);
onMeasureTxt(mIncWeekTxt);
onMeasureTxt(mIncMonTxt);
onMeasureTxt(mOverPerTxt);
onMeasureTxt(mOverPerTxt2);
onMeasureTxt(mOverCountTxt);
mScrollView.sendScroll(MagicScrollView.UP,
0
);
};
};
@Override
protected
void
onCreate(Bundle savedInstanceState) {
super
.onCreate(savedInstanceState);
setContentView(R.layout.magic_scroll_layout);
Rect fram =
new
Rect();
getWindow().getDecorView().getWindowVisibleDisplayFrame(fram);
mWinheight = fram.height();
Log.d(
"winHeight is ====>"
,
""
+ mWinheight);
mScrollView = (MagicScrollView) findViewById(R.id.magic_scroll);
tv_qian = (MagicTextView) findViewById(R.id.tv_qian);
mIncomeTxt = (MagicTextView) findViewById(R.id.income_money);
mTotalMoneyTxt = (MagicTextView) findViewById(R.id.total_money);
mIncTotalTxt = (MagicTextView) findViewById(R.id.income_total_txt);
mIncSevTxt = (MagicTextView) findViewById(R.id.income_sevdays_txt);
mIncWeekTxt = (MagicTextView) findViewById(R.id.income_week_txt);
mIncMonTxt = (MagicTextView) findViewById(R.id.income_month_txt);
mOverPerTxt = (MagicTextView) findViewById(R.id.overperson_percent);
mOverPerTxt2 = (MagicTextView) findViewById(R.id.overperson_percent2);
mOverCountTxt = (MagicTextView) findViewById(R.id.overperson_count);
mContainer = (LinearLayout) findViewById(R.id.container);
tv_qian.setValue(
5360.00
);
mIncomeTxt.setValue(
3.30
);
mTotalMoneyTxt.setValue(
22800.56
);
mIncTotalTxt.setValue(
58.56
);
mIncSevTxt.setValue(
50.00
);
mIncWeekTxt.setValue(
20.00
);
mIncMonTxt.setValue(
40.20
);
mOverPerTxt.setValue(
88.88
);
mOverPerTxt2.setValue(
88.88
);
mOverCountTxt.setValue(
300000000
);
initListener();
mHandler.sendEmptyMessageDelayed(
0
,
1000
);
// 三个圆的故事
infoOperatingIV1 = (ImageView) findViewById(R.id.patientmg_code_img1);
infoOperatingIV2 = (ImageView) findViewById(R.id.patientmg_code_img2);
infoOperatingIV3 = (ImageView) findViewById(R.id.patientmg_code_img3);
// 动画部分
LinearInterpolator lin =
new
LinearInterpolator();
// 匀速运动
DecelerateInterpolator lin2 =
new
DecelerateInterpolator();
// 减速运动
operatingAnim1 = AnimationUtils.loadAnimation(
this
, R.anim.tip1);
operatingAnim1.setInterpolator(lin);
if
(operatingAnim1 !=
null
) {
infoOperatingIV1.startAnimation(operatingAnim1);
}
operatingAnim2 = AnimationUtils.loadAnimation(
this
, R.anim.tip2);
operatingAnim2.setInterpolator(lin);
if
(operatingAnim2 !=
null
) {
infoOperatingIV2.startAnimation(operatingAnim2);
}
operatingAnim3 = AnimationUtils.loadAnimation(
this
, R.anim.tip3);
operatingAnim3.setInterpolator(lin);
if
(operatingAnim3 !=
null
) {
infoOperatingIV3.startAnimation(operatingAnim3);
}
}
private
void
initListener() {
mScrollView.AddListener(tv_qian);
mScrollView.AddListener(mIncomeTxt);
mScrollView.AddListener(mTotalMoneyTxt);
mScrollView.AddListener(mIncTotalTxt);
mScrollView.AddListener(mIncSevTxt);
mScrollView.AddListener(mIncWeekTxt);
mScrollView.AddListener(mIncMonTxt);
mScrollView.AddListener(mOverPerTxt);
mScrollView.AddListener(mOverPerTxt2);
mScrollView.AddListener(mOverCountTxt);
}
private
void
onMeasureTxt(MagicTextView view) {
// 用来获取view在距离屏幕顶端的距离(屏幕顶端也是scrollView的顶端)
view.getLocationInWindow(location);
view.setLocHeight(location[
1
]);
Log.d(
"window y is ====>"
,
""
+ location[
1
]);
}
}
|
总结一下:这个动画需要你自己去计算,我自己的需求是这样的:每一个圆按照120°旋转,坐标分别是(46,50),(53,50+2√3),(53,50-2√3),距上顶点和距左边距。下面是草图,大家自己算算就知道了啊。。另外时间的换算你可以去控制快慢什么的百度吧~属性值这里就不多说了,百度都有~
最后就是说一句,没有做不出来的东西,只有不用心上进的人~虽然很苦逼,但是都是你的Color Life~


![[O9Q9HB]}3M72D2YA3]9HXH.png wKioL1WQtSqBMck4AABgR2wRCJM609.jpg](http://s3.51cto.com/wyfs02/M00/6F/0A/wKioL1WQtSqBMck4AABgR2wRCJM609.jpg)
