Android补间动画之旋转动画

来源:互联网 发布:strtoupper php 编辑:程序博客网 时间:2024/05/17 07:17

今天在项目中遇到了一个需求就是将TextView旋转45度

动画可以在xml中定义也可以在代码中定义个人比较喜欢使用xml所以这里我用的就是xml
首先在res中建立一个anim文件夹名字可以随便起这里我直接上代码
文件目录res/anim/rotate_text.xml

<?xml version="1.0" encoding="utf-8"?><set xmlns:android="http://schemas.android.com/apk/res/android">    <rotate  android:fromDegrees="0"             android:toDegrees="-45"             android:pivotX="0"             android:pivotY="100%"             />            <!--rotate为旋转动画还有其他几个动画我这里就不写了-->             <!--android:fromDegrees="0"  初始角度-->              <!--  android:toDegrees="-45"  结束角度-->               <!--  android:pivotX="0"  和  android:pivotY="0" 代表旋转轴点xy坐标--></set>

然后在代码中的使用

//个人理解获取动画 Animation animation = AnimationUtils.loadAnimation(context, R.anim.trogin_text); //动画结束后是否保留动画在当前位置animation.setFillAfter(true);TextView  tv = new TextView(this);//给当前组件设置动画tv.setAnimation(animation);

好了今天的动画就是这些 其他几个补间动画的使用方法和旋转动画的用法相同

0 0
原创粉丝点击