1、在编写动画的时候需要新建一个xml 新建的步骤是选中res单击右键选择Android resource file 然后弹出一个框 ,然后再Resource Type 里面选择Animation 然后再file name里面写一个xxx.xml就可以

 

 

android 编写动画

android 编写动画

在新建的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.0" android:duration="3000"/>
</set>

MainActivity里面的方法里面写这句带红色的话就可以实现动画效果

public void ImageClick(View view) {  
//加载动画资源文件
Animation alpha= AnimationUtils.loadAnimation(this, R.anim.alpha_anim);
ImageView iv= (ImageView) view;
iv.startAnimation(alpha);
}

 

相关文章:

  • 2021-06-13
  • 2021-11-16
  • 2021-08-25
  • 2022-01-10
猜你喜欢
  • 2022-12-23
  • 2021-09-05
  • 2022-12-23
  • 2021-11-03
  • 2021-05-08
  • 2022-01-08
相关资源
相似解决方案