android空间动画

天在公司做项目,其中有一个模块需要让控件动起来

我再这里用到了动画

先贴出代码吧

//layout              

    android:layout_width="match_parent"

    android:layout_height="match_parent">

                

   

        android:id="@+id/imgpic"

        android:layout_width="wrap_content"

        android:layout_height="wrap_content"

        android:scaleType="center"

        android:src="https://www.yisu.com/zixun/@drawable/left">//图片可更改

                     

                             

   

        android:id="@+id/toggleButton1"

        android:layout_width="wrap_content"

        android:layout_height="wrap_content"

        android:layout_alignParentBottom="true"

        android:layout_centerHorizontal="true"

        android:layout_marginBottom="141dp"

        android:text="ToggleButton"/>

//动画路径 res/anim/tip.xml

 

 

   

        android:fromDegrees="0"  

        android:toDegrees="359"  

        android:duration="1000"  

        android:repeatCount="-1"  

        android:pivotX="50%"  

        android:pivotY="50%"/> ,

,

动画的参数设置:

android: fromDegrees=" 0 ",,//起始角度

,,,,,,,, android: toDegrees=" 359 ",,//

,,,,,,,, android:持续时间=" 1000 ",,,//

,,,,,,,, android: repeatCount=" 1 ",//重复的次数,负数表示一直旋转

,,,,,,,, android: pivotX=?0%”,,,,,//旋转中心的坐标

,,,,,,,, android: pivotY=?0%”/祝辞,

//活动方案com.example.pictween;

进口android.os.Bundle;

进口android.app.Activity;

进口android.view.Menu;

进口android.view.View;

进口android.view.View.OnClickListener;

进口android.view.animation.Animation;

进口android.view.animation.AnimationUtils;

进口android.view.animation.LinearInterpolator;

进口android.widget.ImageButton;

进口android.widget.Toast;

进口android.widget.ToggleButton;

公共类MainActivity延伸活动{

私人动画operatingAnim;

私人ToggleButton togbtn;

私人布尔标志=false;

私人ImageButton imgbtn;

@Override

保护无效alt=" android空间动画">


android空间动画