本文利用TranslateAnimation实现图片的移动动画效果,利用setAnimationListener实现图片的循环移动!
思想很简单,就是在第一个动画结束的时候开始下一个动画。做这个的过程让我感觉很像是在做ppt。
现在感觉很多东西原理真的都是相通的。
首先是设置四个动画效果,利用TranlateAnimation,然后在每个animation的setAnimationListener中启动下一个动画效果。
效果图片如下:
布局文件如下:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".MainActivity">
<RelativeLayout
android:id="@+id/newIcon"
android:layout_centerInParent="true"
android:layout_width="match_parent"
android:layout_height="80dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="40dp"
android:layout_marginRight="20dp"
android:orientation="horizontal">
<RelativeLayout
android:id="@+id/dynamicView"
android:layout_marginTop="10dp"
android:layout_width="60dp"
android:layout_height=