Skip to content

Commit 34546fa

Browse files
Faqiang LvFaqiang Lv
authored andcommitted
动画的简单的测试
1 parent bed281c commit 34546fa

File tree

3 files changed

+64
-2
lines changed

3 files changed

+64
-2
lines changed

app/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ dependencies {
6969
implementation 'com.android.support:design:26.1.0'
7070
implementation 'com.android.support:cardview-v7:26.1.0'
7171
implementation 'de.hdodenhof:circleimageview:2.1.0'
72-
implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
72+
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
7373
implementation "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
7474
implementation 'com.android.support:recyclerview-v7:26.1.0'
7575
implementation 'com.github.CymChad:BaseRecyclerViewAdapterHelper:2.9.34'

app/src/main/AndroidManifest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
android:supportsRtl="true"
2020
android:theme="@style/AppTheme">
2121

22-
<activity android:name=".view.click.ViewClickActivity">
22+
<activity android:name=".animation.AnimationActivity">
2323
<intent-filter>
2424
<action android:name="android.intent.action.MAIN" />
2525

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
package com.lvfq.code.animation
2+
3+
import android.animation.ValueAnimator
4+
import android.os.Bundle
5+
import android.support.v7.app.AppCompatActivity
6+
import android.util.Log
7+
import android.view.Gravity
8+
import android.view.animation.Interpolator
9+
import android.widget.TextView
10+
import com.lvfq.code.R
11+
12+
/**
13+
* AnimationActivity
14+
* @author FaQiang on 2018/9/7 下午12:51
15+
* @Github: <a href="https://github.com/lvfaqiang"/>
16+
* @Blog: <a href="http://blog.csdn.net/lv_fq"/>
17+
* @desc :
18+
*
19+
*/
20+
class AnimationActivity : AppCompatActivity() {
21+
22+
override fun onCreate(savedInstanceState: Bundle?) {
23+
super.onCreate(savedInstanceState)
24+
val textView by lazy {
25+
TextView(this).apply {
26+
width = 150
27+
height = 150
28+
gravity = Gravity.CENTER
29+
textSize = 14f
30+
setTextColor(resources.getColor(R.color.c_1495eb))
31+
}
32+
}
33+
34+
textView.text = "0"
35+
setContentView(textView)
36+
37+
38+
val anim = ValueAnimator.ofInt(1, 2, 3,4).setDuration(3000)
39+
// anim.repeatCount = INFINITE
40+
anim.interpolator = Interpolator {
41+
Log.i("TAG", "value: $it")
42+
it
43+
}
44+
45+
anim.addUpdateListener {
46+
Log.i("TAG1", "value: ${it.animatedValue}")
47+
textView.text = it.animatedValue.toString()
48+
}
49+
50+
anim.start()
51+
52+
textView.setOnClickListener {
53+
if (anim.isStarted) {
54+
anim.cancel()
55+
} else {
56+
anim.start()
57+
}
58+
}
59+
60+
}
61+
62+
}

0 commit comments

Comments
 (0)