1、动画设置:
Tweened Animations:该类Animations提供了旋转、移动、伸展和淡出等效果。Alpha——淡入淡出,Scale——缩放效果,Rotate——旋转,Translate——移动效果。
先在res文件夹下建立一个anim文件夹。在anim文件夹下设置一个相应xml文件。其中设置动画透明效果。
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<alpha android:fromAlpha="1.0"
android:toAlpha="0.3"
android:duration="3000"
/>
</set>
其他效果可以在主函数中代码设置。
public class WelcomeActivity extends AppCompatActivity implements Animation.AnimationListener{
ImageView imageview_welcome;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_welcome);
imageview_welcome = (ImageView) findViewById(R.id.imageview_welcome);
//获取资源动画对象
Animation animation = AnimationUtils.loadAnimation(this, R.anim.welcome_anim);
//设置动画播放的持续时间
animation.setDuration(3000);
//设置动画保留在最后一帧
animation.setFillAfter(true);
//为对话的播放设置监听器
animation.setAnimationListener(this);
//启动这个动画
imageview_welcome.startAnimation(animation);
}