我会一步一步告诉你。这是用于淡入动画。
anim在资源文件夹中以任意名称创建一个 XML 文件。XML的代码如下:
<?xml version="1.0" encoding="UTF-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<alpha
android:fromAlpha="0.0"
android:toAlpha="1.0"
android:interpolator="@android:anim/accelerate_interpolator"
android:duration="1600"
android:repeatCount="0" />
</set>
Run Code Online (Sandbox Code Playgroud)Animation animation;全局创建对象
加载动画
animation = AnimationUtils.loadAnimation(this, R.anim.fadein);
Run Code Online (Sandbox Code Playgroud)设置动画 TextView
tv.startAnimation(animation);
Run Code Online (Sandbox Code Playgroud)通过这种方式,您可以使用任何类型的动画。