MainActivity
public class MainActivity extends Activity {
private Button button;
private boolean flag = true;
private ImageView iv;
private Handler handler;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
final Animation rotate = AnimationUtils.loadAnimation(this,
R.anim.anim_alpha);
button = findViewById(R.id.button);
iv = findViewById(R.id.image);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (flag){
iv.startAnimation(rotate);
}
handler=new Handler() ;
new Thread(new Runnable() {
@Override
public void run() {
SystemClock.sleep(2000);
handler.post(new Runnable() {
@Override
public void run() {
Intent intent = new Intent(MainActivity.this, Activity_MU.class);
startActivity(intent);
finish();
}
});
}
}).start();
}
});
}
}
anim
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:fillAfter="true"
android:fillBefore="true">
<alpha
android:duration="2000"
android:fromAlpha="1"
android:repeatCount="1"
android:repeatMode="reverse"
android:toAlpha="0"/>
<rotate
android:duration="2000"
android:fromDegrees="0"
android:interpolator="@android:anim/accelerate_interpolator"
android:pivotX="50%"
android:pivotY="50%"
android:toDegrees="720" >
</rotate>
<rotate
android:duration="2000"
android:fromDegrees="360"
android:interpolator="@android:anim/accelerate_interpolator"
android:pivotX="50%"
android:pivotY="50%"
android:startOffset="2000"
android:toDegrees="0" >
</rotate>
<scale
android:fromXScale="1"
android:interpolator="@android:anim/decelerate_interpolator"
android:fromYScale="1"
android:toXScale="2.0"
android:toYScale="2.0"
android:pivotX="50%"
android:pivotY="50%"
android:fillAfter="true"
android:repeatCount="1"
android:repeatMode="reverse"
android:duration="2000"
/>
<translate
android:fromXDelta="0"
android:toXDelta="860"
android:fromYDelta="0"
android:toYDelta="0"
android:fillAfter="true"
android:repeatMode="reverse"
android:repeatCount="1"
android:duration="2000">
</translate>
</set>
布局
<LinearLayout
android:layout_height="match_parent"
android:layout_width="match_parent"
android:orientation="vertical"
xmlns:android="http://schemas.android.com/apk/res/android">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/button"
android:text="补间动画"
/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/image"
android:background="@mipmap/ic_launcher_round"/>
</LinearLayout>