先上Java代碼的調用,沒有引用!本身在eclipse中CTRL+ SHIFT+O一下就有了。java
public class StartActivity extends Activity { ImageView im; Animation loadAnimation; //動畫對象 protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_start); ImageView image=(ImageView)findViewById(R.id.imageView1); loadAnimation=AnimationUtils.loadAnimation(getApplicationContext(), R.anim.myanin); image.setAnimation(loadAnimation); loadAnimation.startNow(); } }
再在res文件夾下建立一個anim文件夾,在裏面建立一個myanrm.xml文件以下android
<?xml version="1.0" encoding="utf-8"?> <set xmlns:android="http://schemas.android.com/apk/res/android" android:shareInterpolator="true"> <!-- 循環 --> <rotate android:fromDegrees="0" android:toDegrees="360 " android:pivotX="50%" android:pivotY="50%" android:startOffset="0" android:duration="1000" /> <scale android:fromXScale="1.0" android:toXScale="0.0" android:fromYScale="1.0" android:toYScale="0.0" android:pivotX="50%" android:pivotY="50%" android:startOffset="500" android:duration="500" /> <!-- 透明度 --> <alpha android:fromAlpha="1.0" android:toAlpha="0.0" android:startOffset="500" android:duration="500" /> </set>
佈局文件eclipse
<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:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" tools:context=".StartActivity" > <ImageView android:id="@+id/imageView1" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_centerHorizontal="true" android:layout_centerVertical="true" android:src="@drawable/b" /> </RelativeLayout>
這只是一個簡單實現,更精彩的還要我接着學習了。佈局